I've learned that to have a singleton lazy loading, this is the pattern to use:
private MyObject()
{
}
public static MyObject Instance
{
get { return SingletonCreator.CreatorInstance; }
}
private static class SingletonCreator
{
private static readonly MyObject _instance = new MyObject();
public static MyObject CreatorInstance
{
get { return _instance; }
}
}
But a more simple pattern would be:
private static readonly MyObject _instance = new MyObject();
private MyObject()
{
}
public static MyObject Instance
{
get { return _instance; }
}
This wouldn't be lazy loading. But is this really something that I should bother about in a web application?