Maha

Maha

  • NA
  • 0
  • 326k

NP48 Singleton Program

Oct 2 2007 3:24 PM

Hi Guys

 

Following Singleton class is given in the following website  

http://www.c-sharpcorner.com/UploadFile/faraz.rasheed/SingletonPattern12052005063955AM/SingletonPattern.aspx

 

Complete program will give better understanding. Please anyone can develop appropriate client code (Main method) for this partial Singleton class Program.  

         

Thank you

 

class Singleton

{

    private static Singleton instance;

    private static int numOfReference;

    private string code;

 

    private Singleton()

    {

        numOfReference = 0;

        code = "Maasoom Faraz";

    }

    public static Singleton GetInstance()

    {

        if (instance == null)

        {

            instance = new Singleton();

        }

        numOfReference++;

        return instance;

    }

    public static int Reference

    {

        get { return numOfReference; }

    }

    public string Code

    {

        get { return code; }

        set { code = value; }

    }

}

 


Answers (8)