Added example of C# inline properties (#1464)

This was a really cool & useful trick/feature that I found while
learning C#.
This commit is contained in:
Chris 2016-10-21 11:46:25 -04:00 committed by ven
parent 819d16b7e5
commit d48aef96f1

View File

@ -671,6 +671,10 @@ on a new line! ""Wow!"", the masses cried";
int _speed; // Everything is private by default: Only accessible from within this class. int _speed; // Everything is private by default: Only accessible from within this class.
// can also use keyword private // can also use keyword private
public string Name { get; set; } public string Name { get; set; }
// Properties also have a special syntax for when you want a readonly property
// that simply returns the result of an expression
public string LongName => Name + " " + _speed + " speed";
// Enum is a value type that consists of a set of named constants // Enum is a value type that consists of a set of named constants
// It is really just mapping a name to a value (an int, unless specified otherwise). // It is really just mapping a name to a value (an int, unless specified otherwise).