Given the following simple .NET code, is there any difference between these two, under the hood with respect to the string \"xml\"
?
if (extension.Eq
The answer to your question is: No, you will not see a performance increase.
The C# specification explicitly addresses the situation of identical literal strings in Section 2.4.4.5 String Literals:
Each string literal does not necessarily result in a new string instance. When two or more string literals that are equivalent according to the string equality operator (§7.10.7) appear in the same program, these string literals refer to the same string instance.
Additionally, Section 7.19 Constant expressions states:
[The constant expression] is evaluated at compile-time. The compile-time evaluation of constant expressions uses the same rules as run-time evaluation of non-constant expressions, except that where run-time evaluation would have thrown an exception, compile-time evaluation causes a compile-time error to occur.
This indicates that the const and literal strings are treated the same way.
If you inspect the IL output from the compiler, you will discover that const strings produce the same output as using literal strings in their place.