我在演示 NoStringInterning 时遇到问题
[assembly: System.Runtime.CompilerServices.CompilationRelaxations(System.Runtime.CompilerServices.CompilationRelaxations.NoStringInterning)]
class Program
{
static void Main(string[] args)
{
String s1 = "Friday";
String s2 = "Friday";
String s3 = "Friday";
String s4 = "Friday";
String s5 = "Friday";
String s6 = "Friday";
String s7 = "Friday";
String s8 = "Friday";
String s9 = "Friday";
// etc...
Console.WriteLine(Object.ReferenceEquals(s1, s2));
Console.WriteLine(Object.ReferenceEquals(s1, s3));
Console.WriteLine(Object.ReferenceEquals(s1, s4));
Console.WriteLine(Object.ReferenceEquals(s1, s5));
Console.WriteLine(Object.ReferenceEquals(s1, s6));
Console.WriteLine(Object.ReferenceEquals(s1, s7));
Console.WriteLine(Object.ReferenceEquals(s1, s8));
Console.WriteLine(Object.ReferenceEquals(s1, s9));
// etc...
我已经尝试使用 .NET CLR 2、3、4.. 作为输出,我得到的只是一堆 True。我期待一堆假!