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?
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.
It does return false
if expression
is null
. Perhaps you're misunderstanding the documentation?
This was a pretty popular answer I gave to a similar question.
http://stackoverflow.com/questions/930147/c-get-type-of-null-object/930155#930155
That's like asking what kind of cake would have been in an empty box with no label.