/*Singletone Pattern sample*/

using System;
using System.Drawing;

public class APMMemory
{
    private static APMMemory apmMemory=null;
    string ____processid;
    System.Drawing.Color ____bgColor;

    public static APMMemory GetInstance
    {
        get
        {
            if(apmMemory == null)
            {
                apmMemory=new APMMeory();
                Console.WriteLine("Singletone Pattern sample");
            }
        }
    }
    public string processid
    {
        get{return ____processid;}
        set{___processid=value;}
    }
    public System.Drawing.Color bgColor
    {
        get{return ____bgColor;}
        set{____bgColor=value;}
    }
}
class SampleManage
{
    public void running()
    {
        Console.WriteLine("" + APMMemory.GetInstance.processid);
        Console.WriteLine("" + APMMemory.GetInstance.bgColor);
    }
}
class Program
{
    public static void Main()
    {
        APMMemory.GetInstance.processid = "9999";
        APMMemory.GetInstance.bgColor=System.Drawing.Color.SteelBlue;

        SampleManage nm = new SampleManage();
        nm.running();
    }
}

+ Recent posts