[英]How can I find a static class initializer by reflection in C#?
How can I find a static class initializer in C# using reflection? 如何使用反射在C#中找到静态类初始化器? Even
GetMembers()
invoked on the type of a class does not seem to provide that information. 甚至在类的类型上调用的
GetMembers()
似乎也无法提供该信息。
使用type.TypeInitializer
进行查找。
I found a way to call static constructor by using reflection. 我找到了一种使用反射调用静态构造函数的方法。 Is this what you are looking for.
这是你想要的。
Type myClass = typeof (MyClass); 类型myClass = typeof(MyClass); myClass.TypeInitializer.Invoke(null,null);
myClass.TypeInitializer.Invoke(null,null);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.