Linked Questions

123 votes
25 answers
35k views

Here is a large number of hidden features discussed for variety of languages. Now I am curious about some hidden features of XAML and WPF? One I have found is the header click event of a ListView &...
72 votes
43 answers
43k views

Shell scripts are often used as glue, for automation and simple one-off tasks. What are some of your favorite "hidden" features of the Bash shell/scripting language? One feature per answer Give an ...
227 votes
12 answers
54k views

What is a closure? Do we have them in .NET? If they do exist in .NET, could you please provide a code snippet (preferably in C#) explaining it?
Developer's user avatar
  • 18.9k
55 votes
38 answers
36k views

To cut a long story short: I find the Java antipatterns an indispensable resource. For beginners as much as for professionals. I have yet to find something like this for C#. So I'll open up this ...
131 votes
12 answers
155k views

If I have a switch-case statement where the object in the switch is a string, is it possible to do an IgnoreCase compare? I have for instance: string s = "house"; switch (s) { case "...
Tolsan's user avatar
  • 1,472
169 votes
9 answers
175k views

How do I check to see if an Application Setting is available? i.e. app.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key ="someKey" ...
bitcycle's user avatar
  • 7,852
91 votes
16 answers
24k views

For c# developers that are staring out to learn Java, are there any big underlying differences between the two languages that should be pointed out? Maybe some people may assume things to be the same,...
mrblah's user avatar
  • 104k
125 votes
13 answers
10k views

The following will cause infinite recursion on the == operator overload method Foo foo1 = null; Foo foo2 = new Foo(); Assert.IsFalse(foo1 == foo2); public static bool operator ==(Foo ...
Andrew Jones's user avatar
  • 5,437
130 votes
5 answers
43k views

I'd be interested in some before-and-after c# examples, some non-idiomatic vs idiomatic examples. Non-c# examples would be fine as well if they get the idea across. Thanks.
88 votes
7 answers
90k views

I want to iterate over the alphabet like so: foreach(char c in alphabet) { //do something with letter } Is an array of chars the best way to do this? (feels hacky) Edit: The metric is "least typing ...
Ben Aston's user avatar
  • 56k
106 votes
9 answers
54k views

When doing case-insensitive comparisons, is it more efficient to convert the string to upper case or lower case? Does it even matter? It is suggested in this SO post that C# is more efficient with ...
Parappa's user avatar
  • 7,676
73 votes
8 answers
59k views

It is not possible to fire an event in C# that has no handlers attached to it. So before each call it is necessary to check if the event is null. if ( MyEvent != null ) { MyEvent( param1, param2 ); ...
Tomas Andrle's user avatar
  • 13.4k
83 votes
6 answers
110k views

I'm learning about Events / Delegates in C#. Could I ask your opinion on the naming/coding style I've chosen (taken from the Head First C# book)? Am teaching a friend about this tomorrow, and am ...
Dave Mateer's user avatar
  • 6,652
85 votes
9 answers
13k views

I have seen a few mentions of this idiom (including on SO): // Deliberately empty subscriber public event EventHandler AskQuestion = delegate {}; The upside is clear - it avoids the need to check for ...
serg10's user avatar
  • 32.9k
108 votes
5 answers
11k views

There are two weird operators in C#: the true operator the false operator If I understand this right these operators can be used in types which I want to use instead of a boolean expression and where ...
Jakub Šturc's user avatar
  • 35.9k

15 30 50 per page
1
2
3 4 5
8