The MSDN documentation for the is keyword says:
expression is not null
Why? If MethodThatReturnsNull() is type were called shouldn't that return false since null certainly isn't that type?
The MSDN documentation for the is keyword says:
expression is not null
Why? If MethodThatReturnsNull() is type were called shouldn't that return false since null certainly isn't that type?
It does return false
if expression
is null
. Perhaps you're misunderstanding the documentation?
The only thing you can say for certain about null is that you don't know what it is. Comparing something to null generally has a result of null ...
Q: Does 1 == "I don't know"? A: "I dont know"
Check out this blog post by Eric Lippert.
You can't statically resolve a null.
This was a pretty popular answer I gave to a similar question.
That's like asking what kind of cake would have been in an empty box with no label.