What is the difference between “x is null” and “x == null”?
问题 In C# 7 we can use if (x is null) return; instead of if (x == null) return; Are there any advantages to using the new way (former example) over the old way? Are the semantics any different? Is just a matter of taste? If not, when should I use one over the other? Reference: What’s New in C# 7.0. 回答1: Update: The Roslyn compiler has been updated to make the behavior of the two operators the same when there is no overloaded equality operator . Please see the code in the current compiler results