From 5bbd8419b232bff0baae40506351f733e0e30462 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 10 Oct 2015 22:25:39 -0700 Subject: Added info C# null-propagation Another tool I found useful when learning C# --- csharp.html.markdown | 3 +++ 1 file changed, 3 insertions(+) (limited to 'csharp.html.markdown') diff --git a/csharp.html.markdown b/csharp.html.markdown index 02650038..14ffe4e0 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -443,6 +443,9 @@ on a new line! ""Wow!"", the masses cried"; // ?? is syntactic sugar for specifying default value (coalesce) // in case variable is null int notNullable = nullable ?? 0; // 0 + + // ?. is an operator for null-propogation - a shorthand way of checking for null + nullable?.Print(); // Use the Print() extension method if nullable isn't null // IMPLICITLY TYPED VARIABLES - you can let the compiler work out what the type is: var magic = "magic is a string, at compile time, so you still get type safety"; -- cgit v1.2.3