1

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?

4

4 回答 4

5

It does return false if expression is null. Perhaps you're misunderstanding the documentation?

于 2009-06-12T21:14:32.137 回答
0

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.

于 2009-06-12T21:13:40.580 回答
0

You can't statically resolve a null.

于 2009-06-12T21:14:10.797 回答
0

This was a pretty popular answer I gave to a similar question.

C# get type of null object

That's like asking what kind of cake would have been in an empty box with no label.

于 2009-06-12T21:15:43.990 回答