-
Consider the following code: object o = new not();
if (o is not) { } // Compile error
if (o is not not) { } // Works fine
public class not { } On VS 16.8.3 Roslyn gives me Are there any plans on fixing this (e.g. by making |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This type of scenario was intentionally not (no pun intended) considered. Lowercase type names are bad style in C#, and while we make every effort to not break this type of scenario, it can happen (for example, in C# 9, putting object o = null;
_ = o is @not;
public class not
{
} |
Beta Was this translation helpful? Give feedback.
This type of scenario was intentionally not (no pun intended) considered. Lowercase type names are bad style in C#, and while we make every effort to not break this type of scenario, it can happen (for example, in C# 9, putting
record foo;
in a type always means generate a record namedfoo
, regardless of whether there is a type also namedrecord
). For your scenario, escaping with@
works: