From d48aef96f1b1db80a6d752cf3a076673535c3071 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 21 Oct 2016 11:46:25 -0400 Subject: Added example of C# inline properties (#1464) This was a really cool & useful trick/feature that I found while learning C#. --- csharp.html.markdown | 4 ++++ 1 file changed, 4 insertions(+) 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). -- cgit v1.2.3