using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace HomeService.Utility { /// /// 单例模式 /// public sealed class Singleton where T:new() { private Singleton() { } public static T Instance { get { return SingletonCreator.instance; } } internal class SingletonCreator { static SingletonCreator() { } internal static readonly T instance = new T(); } } }