Damage for singleton

Singleton class
{
Private static Singleton inntleton = null;
Private stlit the ArrayList = null;
// private constructor
Private Singleton ()
{}

public static Singleton Singl ()
{
IF (inntleton == null)
{
inntleton = new new Singleton (HTTP: / /www.amjmh.com/v/);

}
return inntleton;
}
}
then create the singleton object by reflection and comparison

//调用私有方法构造函数
var ass = Assembly.Load("TextCord");
var type = ass.GetType("TextCord.SingLeton");
var singletonCreate = Activator.CreateInstance(type, true);
var singleton = SingLeton.singl();

Console.WriteLine(object.ReferenceEquals(singleton, SingLeton.singl()));//true

 

Guess you like

Origin www.cnblogs.com/hyhy904/p/11498528.html