class SingletonClass
{
ย ย protected static SingletonClass instance = null;
ย ย public static SingletonClass Instance => (instance ?? new SingletonClass());
ย ย
ย ย protected SingletonClass(){ instance = this; }//must be called
}
https://gist.github.com/Yukinyaa/d4fad315acce0092bd4995a8e456e311
์์ฆ ๋ฐ๊ณ ์๋๊ฑฐ์
{
ย ย protected static SingletonClass instance = null;
ย ย public static SingletonClass Instance => (instance ?? new SingletonClass());
ย ย
ย ย protected SingletonClass(){ instance = this; }//must be called
}
https://gist.github.com/Yukinyaa/d4fad315acce0092bd4995a8e456e311
์์ฆ ๋ฐ๊ณ ์๋๊ฑฐ์
- dc official App
๋์ฒดํฌ๋ฅผ ์ํ๋ค ๊ทนํ๋ฐ์ค์.. ์์ธ์ฒ๋ฆฌ์ํ๋ ์ฝ๋๋ณด๋ฉด ์ ๋ ์ ๋
?? ์์๋ - dc App
Singleton + Lazy ์ธ๊ฑฐ๋ฉด Lazy<T>ํด๋์ค๋ฅผ ์ด์ฉํด๋ณด๋๊ฑด ์ด๋จ๊น?
์ .. ์๋ชป๋ณธ๋ฏ ๊ณ ๋งจ..
instance ๋ ๊ทธ๋ฅ ๋๋ฌ๋ null์ธ๋ฐ ์ =null์ ๋ฃ๊ณ ์์ง?
๋ ์๊ฐํ๊ธฐ ํธํ๋ผ๊ณ - dc App