While reviewing some code I noticed the following code construct:
So far I’ve always written my null checks using the following syntax:
I wasn’t aware that this was even possible. Turns out this was introduced in C# 7.
Why would you use the ‘is’ keyword instead of ‘==’? The ‘is’ keyword ignores any operator overloads so you don’t end up with unexpected behavior when you are using operator overloading.
Learned something today? Check!