I have been in a conference and speaker's example has '?.' operator. What is it?
Similar code:
var result = man?.Name;
I have been in a conference and speaker's example has '?.' operator. What is it?
Similar code:
var result = man?.Name;
It's c# 6.0 syntax, Null propagation Operator. It means :
var p = man;
if(p != null)
{
var result = man.Name;
}
else
{
var result = null;
}
More info here: https://msdn.microsoft.com/en-us/magazine/dn802602.aspx
It is called Null-propagating operator in C#-6.0 version.
var result = man?.Name;
is equal to
var temp = man;
var result = (temp != null) ? man.Name : null;