最新下载
热门教程
- 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();
相关文章
- 逃离鸭科夫撬棍图纸获取攻略 11-14
- 洛克王国世界吹笛子任务流程攻略 11-14
- 辉烬废墟统治者打法教学 11-14
- 洛克王国世界冠军树获取攻略 11-14
- 原神机关破谜范式第三关过关攻略 11-14
- 尘白禁区米娅星彩技能详解 11-14