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

@ -672,6 +672,10 @@ on a new line! ""Wow!"", the masses cried";
// 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).
// The approved types for an enum are byte, sbyte, short, ushort, int, uint, long, or ulong. // The approved types for an enum are byte, sbyte, short, ushort, int, uint, long, or ulong.