I am refractoring a line of code from .NET 4.0 to 3.5, the actual code is
if(bar?.foo == "outdated")
bar = new Bar();
Can i refractor these lines in this way and retain the same logic?
if(bar == null || bar.foo == "outdated")
bar = new Bar();
Does the if
evaluation stop after the the bar == null
(since the expression would be true, no matter whether the other part returns true or false) or does it continue to check bar.foo
even if the first part already returned true, and therefore throw a null exception?