The code is as follows:
if(f1)
{
return a1?.a2 ?? a3
}
Can anyone tell the use of these operators here?
The code is as follows:
if(f1)
{
return a1?.a2 ?? a3
}
Can anyone tell the use of these operators here?
first the operator ?? example:
var c = a ?? b;
is equivalent to
var c = a == null ? b : a;
the second one ?. it is to not throw NullReferenceException example:
var c = a?.Name;
is equivalent to
var c = a == null ? null : a.Name;
it is short cuts to avoid ifs and long lines
Did you get it ?