C#에서 싱글톤(Singleton) 클래스 만들기예제
아래 예제 참조 부탁 드립니다.
using System;
public class Singleton
{
private static Singleton instance;
private Singleton() { }
public static Singleton getInstance
{
get
{
if (instance == null)
{
instance = new Singleton();
}
return instance;
}
}
public String sayHello()
{
return "Hello";
}
}
class Test
{
static void Main()
{
Singleton s = Singleton.getInstance;
Console.WriteLine(s.sayHello());
}
}
| 12-27 | 2801 | |||
| 12-11 | 2036 | |||
| 53 | 03-15 | 1854 | ||
| 52 | 01-31 | 2012 | ||
| 51 | 01-31 | 2972 | ||
| 50 | 01-31 | 1554 | ||
| 49 | 01-19 | 1874 | ||
| 48 | 01-11 | 1747 | ||
| 47 | 01-03 | 2320 | ||
| 46 | 12-27 | 2801 | ||
| 45 | 12-19 | 1962 | ||
| 44 | 12-14 | 1944 | ||
| 43 | 12-11 | 2036 | ||
| 42 | 12-09 | 1583 | ||
| 41 | 12-01 | 1809 | ||
| 40 | 12-01 | 2030 | ||
| 39 | 12-01 | 1458 | ||
댓글 없음:
댓글 쓰기