Roy*_*mir 3 .net c# string-interning
String.Intern 有一个特殊的字符串池,以后可以检索.
有没有办法让我知道指定的字符串是从池中获取的,并且是否是新创建的?例如:
string s1 = "MyTest";
string s2 = new StringBuilder().Append("My").Append("Test").ToString();
string s3 = String.Intern(s2);
Console.WriteLine((Object)s2==(Object)s1); // Different references.
Console.WriteLine((Object)s3==(Object)s1); // The same reference.
Run Code Online (Sandbox Code Playgroud)
S3参考VAL 是从池中取出
有什么办法让我知道吗?