Thursday, February 27, 2014

C# Safe Navigation Operator: ?.

http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx

var g1 = parent.child.child.child;
Problem happens if any child is null.

New operator solves this problem
var g1 = parent?.child?.child?.child; 
if (g1 != null) // TODO

No comments:

Post a Comment