Does using the null-conditional operator duplicate null checks? For example
var x = instance?.Property1;
var y = instance?.Property2;
Does that get compiled into this:
if (instance != null)
{
var x = instance.Property1;
var y = instance.Property2;
}
Or this?
if (instance != null)
{
var x = instance.Property1;
}
if (instance != null)
{
var y = instance.Property2;
}
If the former, does it make a difference if there is other code in between both lines? In other words, how smart is the compiler/optimizer?