싱글에 대한 피해

싱글 톤 클래스
{
개인 정적 싱글 inntleton = NULL;
개인 stlit ArrayList에 = NULL;
// 개인 생성자
개인 싱글 ()
{}

공공 정적 싱글 자장하게 ()
{
IF (inntleton == NULL)
{
inntleton = 새로운 새로운 싱글 (HTTP : / /www.amjmh.com/v/)

}
리턴 inntleton;
}
}
다음의 반사와 비교하여 단일 객체를 만들

//调用私有方法构造函数
VAR 엉덩이 = Assembly.Load ( "TextCord");
VAR 타입 = ass.GetType ( "TextCord.SingLeton");
VAR singletonCreate = Activator.CreateInstance로 (유형, TRUE);
VAR 싱글 SingLeton.singl = ();

Console.WriteLine (object.ReferenceEquals (싱글, SingLeton.singl ())); // 사실

 

추천

출처www.cnblogs.com/hyhy904/p/11498528.html