这是一个单身人士班
public sealed class Singleton
{
static Singleton instance=null;
static readonly object padlock = new object();
Singleton()
{
}
public static Singleton Instance
{
get
{
lock (padlock)
{
if (instance==null)
{
instance = new Singleton();
}
return instance;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是static Singleton instance=null; 为什么这是静态的?
| 归档时间: |
|
| 查看次数: |
1398 次 |
| 最近记录: |