C# string concatenation and string interning

前端 未结 2 1276

When performing string concatentation of an existing string in the intern pool, is a new string entered into the intern pool or is a reference returned to the existing strin

相关标签:
2条回答
  • 2020-12-21 04:41

    You can see whether a string has been interned by calling String.IsInterned. The call will return a new string that is either a reference to an interned string equal to the string that was passed as an argument, or null if the string was not interned.

    0 讨论(0)
  • 2020-12-21 04:47

    If you create new strings, they will not automatically be put into the intern pool, unless you concatenate constants compile-time, in which case the compiler will create one string result and intern that as part of the JIT process.

    0 讨论(0)
提交回复
热议问题