Skip to content

Instantly share code, notes, and snippets.

@vgashic
Last active September 17, 2021 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vgashic/c3aea222cfad56330c8e3437c54c7e42 to your computer and use it in GitHub Desktop.
Save vgashic/c3aea222cfad56330c8e3437c54c7e42 to your computer and use it in GitHub Desktop.
Demonstration of elvis (?.) operator
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