C# Syntax Shortcuts

c#, shortcut, syntax

Solution

a = b ? c : d ;

is short for

if (b) a = c; else a = d;

And

int MyProp{get;set;}

is short for

int myVar;
int MyProp{get {return myVar; } set{myVar=value;}}

Also see the code templates in visual studio which allows you to speed coding up.

But note that short code doesn't mean necessarily good code.

Problem

I was wondering if there exists somewhere a collection or list of C# syntax shortcuts. Things as simple omitting the curly braces on `if` statements all the way up to things like the `??` coalesce operator.

Original source

Related problems