What is the difference between "x is null" and "x == null"?

asked9 years ago
last updated5 years ago
viewed135.7k times
Up Vote537Down Vote

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 it just a matter of taste? If not, when should I use one over the other? Reference: What’s New in C# 7.0.