Given a static class using the initializer method:
public static class Foo { // Class members... internal static init() { // Do some initialization... } }
How can I make sure that the initializer is started before Main() ?
The best I can think of is to add this to Foo :
private class Initializer { private static bool isDone = false; public Initializer() { if (!isDone) { init(); isDone = true; } } } private static readonly Initializer initializer = new Initializer();
Will this work or are there any unforeseen reservations? And is there a better way to do this?
Matt
source share