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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With