보다 심플한 C# 싱글턴 만들기

// simple type of c# singleton pattern
public class Communicator
{
    private static Communicator _inst;
    public static Communicator GetInst
    {
        get
        {
            return _inst;
        }
    }
    
    static Communicator()
    {
        _inst = new Communicator();
    }
    
    private Communicator()
    {
        Console.WriteLine("NEW");
    }
}



static 생성자를 통한 싱글턴 만들기.

Yamecoder 야매코더_
C# 2017.01.30 17:43
Powerd by Tistory, designed by criuce
rss