Hidden Features of C#?

Posted by Serhat Özgel on Stack Overflow See other posts from Stack Overflow or by Serhat Özgel
Published on 2008-08-12T16:32:24Z Indexed on 2010/03/08 22:06 UTC
Read the original article Hit count: 973

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

yield by Michael Stum
var by Michael Stum
using() statement by kokos
readonly by kokos
as by Mike Stone
as / is by Ed Swangren
as / is (improved) by Rocketpants
default by deathofrats
global:: by pzycoman
using() blocks by AlexCuse
volatile by Jakub Šturc
extern alias by Jakub Šturc

Attributes

DefaultValueAttribute by Michael Stum
ObsoleteAttribute by DannySmurf
DebuggerDisplayAttribute by Stu
DebuggerBrowsable and DebuggerStepThrough by bdukes
ThreadStaticAttribute by marxidad
FlagsAttribute by Martin Clarke
ConditionalAttribute by AndrewBurns

Syntax

?? operator by kokos
number flaggings by Nick Berardi
where T:new by 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
enum values by lfoust
@variablenames by marxidad
event operators by marxidad
format string brackets by Portman
property accessor accessibility modifiers by xanadont
ternary operator (?:) by JasonS
checked and unchecked operators by Binoj Antony
implicit and explicit operators by Flory

Language Features

Nullable types by Brad Barker
Currying by Brian Leahy
anonymous types by Keith
__makeref __reftype __refvalue by Judah Himango
object initializers by lomaxx
format strings by David in Dakota
Extension Methods by marxidad
partial methods by Jon Erickson
preprocessor directives by John Asbeck
DEBUG pre-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

Visual Studio Features

select block of text in editor by Himadri
snippets by DannySmurf

Framework

TransactionScope by KiwiBastard
DependantTransaction by KiwiBastard
Nullable<T> by IainMH
Mutex by Diago
System.IO.Path by ageektrapped
WeakReference by Juan Manuel

Methods and Properties

String.IsNullOrEmpty() method by KiwiBastard
List.ForEach() method by KiwiBastard
BeginInvoke(), EndInvoke() methods by Will Dean
Nullable<T>.HasValue and Nullable<T>.Value properties by Rismo
GetValueOrDefault method 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

© Stack Overflow or respective owner

Related posts about c#

Related posts about hidden-features

  • Hidden features of MySQL

    as seen on Server Fault - Search for 'Server Fault'
    In the long tradition of having hidden features, let us have a list of hidden features in MySQL. Do put one feature per answer. Also See: Hidden Features of Linux Hidden Features of PowerShell Hidden features of Oracle Database Hidden Features of Windows 2008 Hidden Features of Solaris/OpenSolaris Hidden… >>> More

  • Hidden features of Bash

    as seen on Stack Overflow - Search for 'Stack Overflow'
    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 example and short description of the feature, not just a link to documentation Label the feature using… >>> More

  • Hidden features of classic asp

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I am still a fan of Classic ASP and know a lot of developers still using classic ASP, although by far there are very few features available in ASP, let us list out the most useful and not so well known ones Of course the question is on the lines of the Hidden Features questions listed below.: Hidden… >>> More

  • Hidden features of Python

    as seen on Stack Overflow - Search for 'Stack Overflow'
    What are the lesser-known but useful features of the Python programming language? Try to limit answers to Python core One feature per answer Give an example and short description of the feature, not just a link to documentation Label the feature using bold title as the first line This question… >>> More

  • Hidden Features of MXML

    as seen on Stack Overflow - Search for 'Stack Overflow'
    What are some of the hidden features of MXML? MXML being used in Flex Framework became quite popular language (because Flash Player is something every PC has and Flash Builder, Flash Catalist are quite popular Adobe programms) So at least from the existing features, do you know any that are not… >>> More