65.9K
CodeProject is changing. Read more.
Home

Simple Singleton Pattern in C#

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Nov 8, 2011

CPOL
viewsIcon

7904

You should do it like this:public sealed class MySingleton { public static readonly MySingleton SharedInstance = new MySingleton (); private MySingleton () : base() { }}

You should do it like this:

public sealed class MySingleton 
{
    
    public static readonly MySingleton SharedInstance = new MySingleton ();

    private MySingleton () : base()
    {
    }
}