Last active
September 17, 2021 09:27
-
-
Save vgashic/c3aea222cfad56330c8e3437c54c7e42 to your computer and use it in GitHub Desktop.
Demonstration of elvis (?.) operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
List<int> list = null; | |
// if we use only list.Count, it will throw null reference exception | |
Console.WriteLine($"List count is {list?.Count}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment