So if you have a class that contains static fields, there is a static method that gets called to initialize these fields at startup (before any class instances are created). If you look at the IL, the method looks like this:
.method private hidebysig specialname rtspecialname static
void .cctor() cil managed
{
// Code size 11 (0xb)
.maxstack 8
.line 25,25 : 9,42 ''
IL_0000: ldc.i4 0x3039
IL_0005: stsfld int32 TestIL.TestClass1::m_int
.line 16707566,16707566 : 0,0 ''
IL_000a: ret
} // end of method TestClass1::.cctorMy question is, how can one get this method via reflection at runtime?
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.