短版:
在C#code
typeof(string).GetField("Empty").SetValue(null, "Hello world!");
Console.WriteLine(string.Empty);
编译和运行的时候,给人的输出世界,你好!
在.NET 4.0和更早的版本,但给,
.NET 4.5和.NET 4.5.1下。
when compiled and run, gives output "Hello world!"
under .NET version 4.0 and earlier, but gives ""
under .NET 4.5 and .NET 4.5.1.
如何写一个字段被忽略这样的,或者,谁重置这个领域?
How can a write to a field be ignored like that, or, who resets this field?
更长的版本:
我从来没有真正理解为什么的String.Empty
字段(也称为 [mscorlib程序] System.String ::空缺
)是不是常量
(又名文字
),请参阅的