Are there particular instances where I should (or shouldn't?) be using "using" blocks:  using(SomeType t = new SomeType()){     ... }
4191
User  answered the wonderful  question by mentioning the using keyword. Can you elaborate on that? What are the uses of using?
2138
Where or when would one would use namespace aliasing like  using someOtherName =  System.Timers.Timer;  It seems to me that it would just add more confusion to understanding the language.
78110
Is there any advantage of using     instead of  ?   As far as I can tell the following fragments are almost equivalent:  1. Semaphore  final Semaphore sem = new Semaphore(0); for (int i = 0; i &lt; num_threads; ++ i) {   Thread t = new Thread() {     public void run()     {       try       {         doStuff();       }       finally       {         sem.release();       }     }   };   t.start(); }  sem.acquire(num_threads);   2: CountDownLatch  final CountDownLatch latch = new CountDownLatch(num_threads); for (int i = 0; i &lt; num_threads; ++ i) {   Thread t = new Thread() {     public void run()     {       try       {         doStuff();       }       finally       {         latch.countDown();       }     }   };   t.start(); }  latch.await();   Except that in case #2 the latch cannot be reused and more importantly you need to know in advance how many threads will be created (or wait until they are all started before creating the latch.)  So in what situation might the latch be preferable?
11253
When you have code like the following:   static T GenericConstruct&lt;T&gt;() where T : new() {     return new T(); }   The C# compiler insists on emitting a call to Activator.CreateInstance, which is considerably slower than a native constructor.   I have the following workaround:  public static class ParameterlessConstructor&lt;T&gt;     where T : new() {     public static T Create()     {         return _func();     }      private static Func&lt;T&gt; CreateFunc()     {         return Expression.Lambda&lt;Func&lt;T&gt;&gt;( Expression.New( typeof( T ) ) ).Compile();     }      private static Func&lt;T&gt; _func = CreateFunc(); }  // Example: // Foo foo = ParameterlessConstructor&lt;Foo&gt;.Create();   But it doesn't make sense to me why this workaround should be necessary.
1296
Why isn't  generic?    Seems like Collection&lt;E&gt; could have boolean remove(E o);   Then, when you accidentally try to remove (for example) Set&lt;String&gt; instead of each individual String from a Collection&lt;String&gt;, it would be a compile time error instead of a debugging problem later.
14961
This may be a generic OOP question. I wanted to do a generic comparison between an interface and an abstract class on the basis of their usage.   When would one want to use an interface and when would one want to use an abstract class?
26383
I often encounter a problem when writing sentences in mathematical contexts, where one "does something" in order to "obtain something." These sentences typically have the form "using X, one can do Y," where generally X is a mathematical rule or function, and Y is its result. I never know if I should put "by" before the present participle. I have this problem mainly with the verb "using," but this is not the only verb that gives me trouble.  Here are some examples:    (by) using Theorem 2, one can prove that... We obtain the result (by) expanding the function ... (by) differentiating w.r.t. the 2nd variable, we obtain ... (by) taking the integer part of F, one can compute...
48241
If 'Test' is an ordinary class, is there any difference between:  Test* test = new Test;   and  Test* test = new Test();
120327
Depending on our point of view, we offer different approaches to address(ing?) a same issue.   Should I use &mdash;ing in this context, and if yes, why?
84974
int fn();  void whatever() {     (void) fn(); }   Is there any reason for casting an unused return value to void, or am I right in thinking it's a complete waste of time?  Follow up:   Well that seems pretty comprehensive.  I suppose it's better than commenting an unused return value since self documenting code is better than comments. Personally, I'll turn these warnings off since it's unnecessary noise.    I'll eat my words if a bug escapes because of it...
11
I've always been one to simply use:  List&lt;String&gt; names = new ArrayList&lt;&gt;();   I use the interface as the type name for portability, so that when I ask questions such as these I can rework my code.    When should  be used over  and vice-versa?
83564
I know VB.Net and am trying to brush up on my C#.  Is there a With block equivalent in C#?  Thanks
22625
MyClass[] array; List&lt;MyClass&gt; list;   What are the scenarios when one is preferable over the other? And why?
79065
I'm trying to figure out which of these interfaces I need to implement. They both essentially do the same thing. When would I use one over the other?
46378
Can someone explained, as detailed as possible, the differences between the following types?  List List&lt;Object&gt; List&lt;?&gt;   Let me make this more specific. When would I want to use  // 1  public void CanYouGiveMeAnAnswer(List l) { }  // 2 public void CanYouGiveMeAnAnswer(List&lt;Object&gt; l) { }  // 3 public void CanYouGiveMeAnAnswer(List&lt;?&gt; l) { }
36880
Oftentimes, I want to include code samples in a list, for example:   Item One Item Two, for example: private bool ItemTwo() {     return this.IFeelLucky; } Item Three   The problem is that there isn't a good and intuitive way to do this using . It's doable, but you have to do some formatting black-magic to get it that way, which is just not "nice" to deal with.  Source that produces this:  1. Item One 2. Item Two, for example: &lt;br/>&lt;br/>&lt;pre>&lt;code>private bool ItemTwo()     {         return this.IFeelLucky;     }&lt;/code>&lt;/pre> 3. Item Three    I would love to just be able to do it this way:  1. Item One 2. Item Two, for example:      private bool Test()     {         return this.IFeelLucky;     }  3. Item Three  Which results in, well, this:   Item One Item Two, for example:  private bool Test() {     return this.IFeelLucky; } Item Three
341
Quote from :     The only portable way of using templates at the moment is to implement them in header files by using inline functions.   Why is this?  (Clarification: header files are not the only portable solution. But they are the most convenient portable solution.)