public sealed class Singleton { private static volatile Singleton uniqueInstance; private static readonly object locker = new object(); private Singleton() { var cache = HttpContext.Current.Cache; } public static Singleton GetInstance() { if (uniqueInstance == null) { lock (locker) { if (uniqueInstance == null) { uniqueInstance = new Singleton(); } } } return uniqueInstance; } public int Number() { return 1; } public int Number(int i = 0) { return i; } }
联系客服