I'm rebuilding a library programmed in C # and need help with a Switch
statement, I have the following code snippet using the <PrivateImplementationDetails> .ComputeStringHash ()
function generated during compilation. My question is, what is the function that I should use? Will I get the same result using sss.GetHashCode()
?
Currently the error that is presented to me is Can not resolve symbol 'PrivateImplementationDetails'
.
switch (<PrivateImplementationDetails>.ComputeStringHash(sss)) {
case 0x1315fc:
if (sss == "ASD") {
break;
}
goto Label_0105;
case 0x15c3dc:
if (sss == "JKL") {
break;
}
goto Label_0105;
}
At the time the question was asked, the generated IL was relatively new, so the decompilers hadn't been updated to support it. Essentially the decompiler revealed some of the underlying .NET framework code and the hash function used to support string switch statements.
Now, a year or so later, the decompilers have been updated so they should just show a switch
statement like this:
switch (sss)
{
case "ASD":
// do something
break;
case "JKL":
// do something
break
}
I've tested this with DotPeek and can confirm it shows this correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With