#Net5 – C#9 logical operators “is” and “is not” are super cool 🆒🆒🆒

Buy Me A Coffee

Hi !

In the line of good features, that are also nice to read, the new use of is and is not is a huge improvement in readability.

As usual, old school validation for objects and types:

// old school
if(!(testObj is MyClass)) {...}

And now, we can type the validation with some style:

// C# 9 style
if(testObj is not MyClass) {...}

I like this new one 👆, now null / not null and other validations will be the same. With an improed readability !

Happy coding!

Greetings

El Bruno


References


¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

One thought on “#Net5 – C#9 logical operators “is” and “is not” are super cool 🆒🆒🆒

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.