Changed behavior of string.Empty (or System.String::Empty) in .NET 4.5

后端 未结 3 1296
温柔的废话
温柔的废话 2020-12-05 01:48

Short version:

The C# code

typeof(string).GetField(\"Empty\").SetValue(null, \"Hello world!\");
Console.WriteLine(string.Empty);
         


        
3条回答
  •  庸人自扰
    2020-12-05 02:35

    I don't have an answer, juste some hint, maybe.

    The only difference I see between String::Empty and System.Diagnostics.Debugger::DefaultCategory is the first one is tagged with __DynamicallyInvokableAttribute.

    I dont' known the meaning of this undocumented attribute. A question about this attribute has been asked on SO: What is the __DynamicallyInvokable attribute for?

    I can only suppose that this attribute is catch by the runtime to do some caching ?

提交回复
热议问题