最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
单件(C#中的设计模式,原创)
时间:2022-07-02 18:07:16 编辑:袖梨 来源:一聚教程网
作标记是不好的,你刚才那个是一个标准的单件设计模式,不过得改一下。
public class SomeClass
{
private static SomeClass _instance;
protected SomeClass
{
//do you do;
}
public static SomeClass getInstance()
{
if(_instance==null)
{
_instance=new SomeClass();
}
return _instance;
}
}
使用时请这样使用
SomeClass a=SomeClass.getInstance();
public class SomeClass
{
private static SomeClass _instance;
protected SomeClass
{
//do you do;
}
public static SomeClass getInstance()
{
if(_instance==null)
{
_instance=new SomeClass();
}
return _instance;
}
}
使用时请这样使用
SomeClass a=SomeClass.getInstance();
相关文章
- 迅捷 FWR310 无线路由器端口映射设置指南 08-11
- 迅捷 FW150R 无线路由器端口映射设置指南 08-11
- 迅捷 FWD105 无线路由器一体机WDS桥接设置 08-11
- 迅捷 FW325R 无线路由器IP与MAC地址绑定设置 08-11
- 方舟生存进化琥珀获取指南 08-11
- 迅捷 FW150R 无线路由器作为交换机设置 08-11