mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
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:
parent
819d16b7e5
commit
d48aef96f1
@ -672,6 +672,10 @@ on a new line! ""Wow!"", the masses cried";
|
||||
// can also use keyword private
|
||||
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
|
||||
// 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.
|
||||
|
Loading…
Reference in New Issue
Block a user