C# Singleton单例模式
public class Singleton<T> where T : new() { private static object _locker = new object(); private static T _instance; public static T Instance { get { if (_instance == null) { lock (_locker) { if (_instance == null) { _instance = new T(); } } } return _instance; } } }

浙公网安备 33010602011771号