I'm not sure if this works. I'm not that familiar with how switch statements actually compare the things.
In fact, during lowering (a step in compilation) the switch is transformed to an nested if, in some cases to a binary search tree to optimize for efficiency.
From what I've seen switch only works with actual strings - an example of something that DOES work is nameof(thing), but that's because the result is a string - so I always just use ToLower() as the argument I'm passing into a switch. The other option is if you KNOW where the caps might be, just create a fall-through for it...
case "ThisThing":
case "thisthing":
dostuff;
break;
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I'm not sure if this works. I'm not that familiar with how
switchstatements actually compare the things.In fact, during lowering (a step in compilation) the
switchis transformed to an nestedif, in some cases to a binary search tree to optimize for efficiency.From what I've seen switch only works with actual strings - an example of something that DOES work is nameof(thing), but that's because the result is a string - so I always just use ToLower() as the argument I'm passing into a switch. The other option is if you KNOW where the caps might be, just create a fall-through for it...
case "ThisThing":
case "thisthing":
dostuff;
break;