Simple Singleton Pattern in C#
Another alternative: class Singleton { public static Singleton m_Instance; //Prevent instance creation from other classes private Singleton() { } public static Singleton Instance { get { return m_Instance ?? (m_Instance = new Singleton()); } ...
Another alternative:
class Singleton
{
public static Singleton m_Instance;
//Prevent instance creation from other classes
private Singleton() { }
public static Singleton Instance
{
get { return m_Instance ?? (m_Instance = new Singleton()); }
}
}
Could you comment pros and cons with alternative-3?