1. 最简单粗暴的单例模式【线程安全】
//定义
public class Singleton
{
private static readonly Singleton instance = new Singleton();
public static Singleton Instance => instance;
public void Action1()
{
Console.WriteLine("Action 1 trigged");
}
}
//使用
var myInstance = Singleton.Instance;
myInstance.Action1();