diff options
author | Chris <csuich2@gmail.com> | 2016-10-21 11:46:25 -0400 |
---|---|---|
committer | ven <vendethiel@hotmail.fr> | 2016-10-21 17:46:25 +0200 |
commit | d48aef96f1b1db80a6d752cf3a076673535c3071 (patch) | |
tree | 7356441032c4b862cf0e3bf8bac97ea0e7bbeed3 /csharp.html.markdown | |
parent | 819d16b7e53a803ae472f7057190703e5d849a14 (diff) |
Added example of C# inline properties (#1464)
This was a really cool & useful trick/feature that I found while
learning C#.
Diffstat (limited to 'csharp.html.markdown')
-rw-r--r-- | csharp.html.markdown | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/csharp.html.markdown b/csharp.html.markdown index 2cacfc00..442700a6 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -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. // 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). |