Hi all,
I've been looking at the article on creating static constructors in c# here:
http://csharpindepth.com/Articles/General/Singleton.aspx
Now, one option he doesn't mention is using a simple static constructor. Is there any issue with doing something like the below? If it works, it seems simpler than his complicated solutions IMHO.
public static class ServiceFactory
{
static ServiceFactory()
{
container = new Foo();
}
static Foo container;
public static Instance {
get {
return container;
}
}
}
The reason i ask is i'm doing a code review and want to leave it as-is if it's fine.