c# - How to ensure that a static constructors is called without calling any member -


i have class static constructor.

i want static constructor called without calling or using of members, if constructor has not been called already.

i tried using reflection. reflection can invoke static constructor (many times), cannot find out if has been called before.

how do this?

edit
not 1 class talking about, more. lets say, classes marked special attribute.

you can use runtimehelpers.runclassconstructor method (assuming correctly understood trying do...)

runtimehelpers.runclassconstructor(typeof(yourtype).typehandle); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -