你好,
我正在尝试在“电子钱包”类中将双重付款称为“
但是当我尝试这样做时,会出现此错误:
Member'Mc_DOnalds.Program.Paying' cannot be accessed with an instance reference; qualify it with a type name instead.
这在电子钱包课程中。
class Wallet
{
public double WalletCustomer = 100;
Program Betalen = new Program();
public void Pay()
{
WalletCustomer = (WalletCustomer - Betalen.Paying);
}
}
}
这在Program.cs中
public static double Paying = 0;
最佳答案
因为Paying
是静态的,所以您无需创建该类的实例即可访问该属性。试试看(看看我如何访问Program.Paying
):
class Wallet
{
public double WalletCustomer = 100;
public void Pay()
{
WalletCustomer = (WalletCustomer - Program.Paying);
}
}
}