News for hackers. Stuff that matters.
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.
Re:C# Pattern Matching by eyegor on Tuesday February 04, 2020 @10:45PM (#22243826)
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.s
Re:C# Pattern Matching by earenndil on Wednesday February 05, 2020 @03:16AM (#22244920)
why not add an operator so you can say (x !is null)?
Re:C# Pattern Matching by gregoryl on Wednesday February 05, 2020 @05:17AM (#22245517)
Largely because (x is null) is a silly workaround to an uncommon and easily avoided problem (bad operator overloading).