OO的封装,一个实例,static method, property, construction method.
三种单件的实现
- Simple Singleton
Class Singleton {private Singleton(); public static Getinstanse(){return new Singleton();}}
- Static Singleton
Class Singleton{ public static readonly Singleton Instance = new Singleton(); }
- MultiThread Singleton
Private static volatile Singleton instance = null;
Lock(LockHelper)
.Net Framework 中的Singleton例子
Type Object
C1.GetType(); == C2.GetType();
HttpContext.Current Object
类别:Programming 查看评论
文章来源:http://hi.baidu.com/hongchaol/blog/item/e054d143632cd11372f05d4c.html