C# 静态构造函数实现单例

使用静态构造函数只执行一次的特性,创建单例

public class SingletonClass
{
    private SingletonClass()=> Thread.Sleep(1000);
    static SingletonClass()=> _instance = new SingletonClass();
    private static readonly SingletonClass _instance;
    public static SingletonClass GetInstance()=> _instance;
}