When I have a nullable long, for example, is there any difference between
myNullableLong.HasValue
and
myNullableLong != null
… or is it just 'syntactic sugar'?
c++nullable
When I have a nullable long, for example, is there any difference between
myNullableLong.HasValue
and
myNullableLong != null
… or is it just 'syntactic sugar'?
Best Answer
It's just syntactic sugar. They will behave exactly the same way - the nullity test actually gets compiled into a call to
HasValue
anyway.Sample:
IL: