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 it just a matter of taste? If not, when should I use one over the other?

Reference: What’s New in C# 7.0.

3 Answers
3

Leave a Comment