案例展示
SubMenuManage類中的實例化代碼如下:
static SubMenuManage sub_this;
public static SubMenuManage Instance()
{
if (sub_this == null)
{
sub_this = new SubMenuManage();
}
return sub_this;
}
其他類中調用SubMenuManage類中的函數代碼如下:
SubMenuManage.Instance().StartData(paraSet);
總結如下:
在A類中編寫實例化A類的函數
static A(類的名字) A_this;
public static A Instance()
{
if (A_this == null)
{
A_this = new A();
}
return A_this;
}
在其他類中調用A類中的內容代碼
A.Instance().[A 類中的函數、變量等參數];