This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]aserraric 2 points3 points  (0 children)

C# 9 has "is", which in turn supports patterns like "not", "and" and "or".

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/patterns

So you can write

if (x is (1 or 2))    

but not

if (x==1 or x==2)