Despite what you think, string x = null actually nothing. This "nothing" is assigned to a variable of type string.
Testing your switch is basically the same as null is string , which has been false for a long time. This is a common problem when evaluating types using generics, but it also has its plus points.
Under the hood is used as zero-checked. Therefore, he cannot return the truth. You could say that the logic for the is operator is as follows:
is = (null as string) != null
Patrick Hofman Mar 22 '17 at 11:53 on 2017-03-22 11:53
source share