Fields in HttpMethods cannot be used in switch
vanillajonathan opened this issue · comments
The fields are declared as public static readonly string
hence cant be used in a switch statement.
Why aren't these declared as constants instead of static readonly?
Can't do the very fast ReferenceEquals
on a constant
Can't do the very fast
ReferenceEquals
on a constant
Is this true? I thought string constants are interned?
Not across assembly boundaries
Anyway, this has been discussed time and time again, and is definitely a duplicate; #795
Not across assembly boundaries
@halter73 says otherwise... #712 (comment) 😉
https://github.com/dotnet/coreclr/issues/14208#issuecomment-332586251
FYI, literal strings are OFTEN interned, but are not guaranteed to be interned.
It's hard to argue with Vance 😂
As a guess you could use a pattern matching switch to use a switch anyway?
Dup of a few bugs as @khellang correctly points out :)