Linked Questions
69 questions linked to/from What are your favorite extension methods for C#? (codeplex.com/extensionoverflow)
5
votes
3
answers
581
views
Is there an existing library of extension methods for C#? or share your own [duplicate]
Possible Duplicate:
Post your extension goodies for C# .Net (codeplex.com/extensionoverflow)
I'm fond of C# 3.0. One of my favorite parts is extension methods.
I like to think of extension ...
6
votes
0
answers
421
views
What are your favorite custom extension methods? [duplicate]
Duplicate:
Post your extension goodies for C# .Net (codeplex.com/extensionoverflow)
Let's create a list of your favorite extension methods. To qualify it should be an extension method you use often ...
1472
votes
296
answers
762k
views
Hidden Features of C#? [closed]
This came to my mind after I learned the following from this question:
where T : struct
We, C# developers, all know the basics of C#. I mean declarations, conditionals, loops, operators, etc.
Some ...
972
votes
319
answers
504k
views
Strangest language feature
What is, in your opinion, the most surprising, weird, strange or really "WTF" language feature you have encountered?
Please only one feature per answer.
363
votes
407
answers
314k
views
What's your most controversial programming opinion?
This is definitely subjective, but I'd like to try to avoid it becoming argumentative. I think it could be an interesting question if people treat it appropriately.
The idea for this question came ...
590
votes
49
answers
1.1m
views
Best way to reverse a string
I've just had to write a string reverse function in C# 2.0 (i.e. LINQ not available) and came up with this:
public string Reverse(string text)
{
char[] cArray = text.ToCharArray();
string ...
736
votes
20
answers
471k
views
C# difference between == and Equals()
I have a condition in a silverlight application that compares 2 strings, for some reason when I use == it returns false while .Equals() returns true.
Here is the code:
if (((ListBoxItem)lstBaseMenu....
208
votes
28
answers
624k
views
How do you convert a DataTable into a generic list?
Currently, I'm using:
DataTable dt = CreateDataTableInSomeWay();
List<DataRow> list = new List<DataRow>();
foreach (DataRow dr in dt.Rows)
{
list.Add(dr);
}
Is there a better/magic ...
385
votes
7
answers
191k
views
Use of "this" keyword in formal parameters for static methods in C#
I've come across several instances of C# code like the following:
public static int Foo(this MyClass arg)
I haven't been able to find an explanation of what the this keyword means in this case. Any ...
158
votes
18
answers
88k
views
Named string formatting in C#
Is there any way to format a string by name rather than position in C#?
In python, I can do something like this example (shamelessly stolen from here):
>>> print '%(language)s has %(#)03d ...
73
votes
40
answers
13k
views
What is the best or most interesting use of Extension Methods you've seen? [closed]
I'm starting to really love extension methods... I was wondering if anyone her has stumbled upon one that really blew their mind, or just found clever.
An example I wrote today:
Edited due to other ...
77
votes
8
answers
3k
views
How to combine || operators in condition statement [duplicate]
Instead of
if (foo == "1" || foo == "5" || foo == "9" ... )
I like to combine them similar to the following (which doesn't work):
if (foo == ("1" || "5" || "9" ... ))
Is that possible?
60
votes
14
answers
80k
views
How to double buffer .NET controls on a form?
How can I set the protected DoubleBuffered property of the controls on a form that are suffering from flicker?
79
votes
7
answers
92k
views
Is there a shorter/simpler version of the for loop to anything x times?
Usually we do something like a for or while loop with a counter:
for (int i = 0; i < 10; i++)
{
list.Add(GetRandomItem());
}
but sometimes you mix up with boundaries. You could use a while ...
55
votes
7
answers
83k
views
How do I make an eventhandler run asynchronously?
I am writing a Visual C# program that executes a continuous loop of operations on a secondary thread. Occasionally when that thread finishes a task I want it to trigger an eventhandler. My program ...