问题描述
你好
我有这个班级
命名空间用户
{
公共类ApplicationData
{
私有静态ApplicationData appData = null;
private string nesto;
public static ApplicationData getInstance()
{
if(appData == null)
{
appData = new ApplicationData();
}
返回appData;
}
公共字符串Nesto
{
get
{
返回nesto;
}
set {nesto = value; }
}
}
}
$ b我所有表格上的$ b我必须使用Nesto,但我不知道如何将这个类调用到我的表单
Hello
I have this class
namespace User
{
public class ApplicationData
{
private static ApplicationData appData = null;
private string nesto;
public static ApplicationData getInstance()
{
if (appData == null)
{
appData = new ApplicationData();
}
return appData;
}
public string Nesto
{
get
{
return nesto;
}
set { nesto = value; }
}
}
}
on all my forms I have to use Nesto but I don't know how to call this class to my forms
推荐答案
ApplicationData obj= ApplicationData.getInstance();
第一次创建 ApplicationData 类的实例。然后再次尝试调用它将限制的这个过程。
希望这有帮助
It will create an instance of ApplicationData class on the first time. Then again you try to call this process it will restrict .
Hope this helps
这篇关于从每个表单上的公共类获取实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!