Skip to content

Instantly share code, notes, and snippets.

@alexeystrakh
Created May 27, 2015 19:45
Show Gist options
  • Save alexeystrakh/cdde21079276f3bfe318 to your computer and use it in GitHub Desktop.
Save alexeystrakh/cdde21079276f3bfe318 to your computer and use it in GitHub Desktop.
NullCheck C# 5
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var a = new A { };
Console.WriteLine(string.Format("Result = [{0}]", a?.B?.Foo));
}
}
public class A
{
public B B { get; set; }
}
public class B
{
public bool Foo { get; set; }
}
@alexeystrakh
Copy link
Author

Result = []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment