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
Post a Comment