请问单件模式中为什么要加sealed ?
1.请问为什么要限制继承呢?
2.刚刚测试了下,在构造函数是私有的情况下貌似不能继承?
呵呵~~~先谢谢大家了~ 呵呵
public sealed class Singleton
2{
3 static Singleton instance=null;
4 static readonly object padlock = new object();
5
6 Singleton()
7 {
8 }
9
10 public static Singleton Instance
11 {
12 get
13 {
14 lock (padlock)
15 {
16 if (instance==null)
17 {
18 instance = new Singleton();
19 }
20 return instance;
21 }
22 }
23 }
24}
25