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 of us even mastered the stuff like Generics, anonymous types, lambdas, LINQ, ...
But what are the most hidden features or tricks of C# that even C# fans, addicts, experts barely know?
Here are the revealed features so far:
Keywords
- yieldby Michael Stum
- varby Michael Stum
- using()statement by kokos
- readonlyby kokos
- asby Mike Stone
- as/- isby Ed Swangren
- as/- is(improved) by Rocketpants
- defaultby deathofrats
- global::by pzycoman
- using()blocks by AlexCuse
- volatileby Jakub Šturc
- extern aliasby Jakub Šturc
Attributes
- DefaultValueAttributeby Michael Stum
- ObsoleteAttributeby DannySmurf
- DebuggerDisplayAttributeby Stu
- DebuggerBrowsableand- DebuggerStepThroughby bdukes
- ThreadStaticAttributeby marxidad
- FlagsAttributeby Martin Clarke
- ConditionalAttributeby AndrewBurns
Syntax
- ??(coalesce nulls) operator by kokos
- Number flaggings by Nick Berardi
- where T:newby Lars Mæhlum
- Implicit generics by Keith
- One-parameter lambdas by Keith
- Auto properties by Keith
- Namespace aliases by Keith
- Verbatim string literals with @ by Patrick
- enumvalues by lfoust
- @variablenames by marxidad
- eventoperators by marxidad
- Format string brackets by Portman
- Property accessor accessibility modifiers by xanadont
- Conditional (ternary) operator (?:) by JasonS
- checkedand- uncheckedoperators by Binoj Antony
- implicit and explicitoperators by Flory
Language Features
- Nullable types by Brad Barker
- Anonymous types by Keith
- __makeref __reftype __refvalueby Judah Himango
- Object initializers by lomaxx
- Format strings by David in Dakota
- Extension Methods by marxidad
- partialmethods by Jon Erickson
- Preprocessor directives by John Asbeck
- DEBUGpre-processor directive by Robert Durgin
- Operator overloading by SefBkn
- Type inferrence by chakrit
- Boolean operators taken to next level by Rob Gough
- Pass value-type variable as interface without boxing by Roman Boiko
- Programmatically determine declared variable type by Roman Boiko
- Static Constructors by Chris
- Easier-on-the-eyes / condensed ORM-mapping using LINQ by roosteronacid
- __arglistby Zac Bowling
Visual Studio Features
- Select block of text in editor by Himadri
- Snippets by DannySmurf
Framework
- TransactionScopeby KiwiBastard
- DependantTransactionby KiwiBastard
- Nullable<T>by IainMH
- Mutexby Diago
- System.IO.Pathby ageektrapped
- WeakReferenceby Juan Manuel
Methods and Properties
- String.IsNullOrEmpty()method by KiwiBastard
- List.ForEach()method by KiwiBastard
- BeginInvoke(),- EndInvoke()methods by Will Dean
- Nullable<T>.HasValueand- Nullable<T>.Valueproperties by Rismo
- GetValueOrDefaultmethod by John Sheehan
Tips & Tricks
- Nice method for event handlers by Andreas H.R. Nilsson
- Uppercase comparisons by John
- Access anonymous types without reflection by dp
- A quick way to lazily instantiate collection properties by Will
- JavaScript-like anonymous inline-functions by roosteronacid
Other
- netmodules by kokos
- LINQBridge by Duncan Smart
- Parallel Extensions by Joel Coehoorn
 
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    
 
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
 
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    
 
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    