Is it possible to set this static private member of a static class with reflection?

后端 未结 2 1545
别跟我提以往
别跟我提以往 2021-02-05 01:52

I have a static class with static private readonly member that\'s set via the class\'s static constructor. Below is a simplified example.

2条回答
  •  时光说笑
    2021-02-05 02:54

    This "null rule" also applies to FieldInfo.GetValue() for a static field, e.g.,

    Console.Writeline((string)(field.GetValue(null)));
    

提交回复
热议问题