简体   繁体   中英

How can I find a static class initializer by reflection in C#?

How can I find a static class initializer in C# using reflection? Even GetMembers() invoked on the type of a class does not seem to provide that information.

使用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.TypeInitializer.Invoke(null,null);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM