Re:C# Pattern Matching
by Serow225 on Tuesday February 04, 2020 @09:41PM
(#22243525)
a number of the C# lang developers prefer (x is object) for the latter, FWIW.
[ Parent
| on HN ]
Yep, looking at the IL they are equivalent. And it definitely makes code prettier due to reduced parentheses. This is also true for generics.
Doing (x != null), !(x is null), or (x is object) all become:
ldloc.s
ldnull
cgt.un
stloc.swhy not add an operator so you can say (x !is null)?