/*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();
}
}
'c# 언어 > 중급과정' 카테고리의 다른 글
JsonConvert.DeserializeObject, JsonConvert.SerializeObject (0) | 2022.11.16 |
---|---|
WM_COPYDATA를 이용한 데이타 주고받기 (0) | 2022.11.09 |
C Pattern(C로 만드는 Interface) (0) | 2022.04.14 |
c# using - statement(File및 Font와 같은 클래스들에 유용) (0) | 2022.04.11 |
SQLite Conn,Open,Create Table,Data Insert,Select (0) | 2022.04.07 |