你好,
我正在尝试从类“钱包”中调用双重支付 但是当我尝试这样做时,它给出了这个错误:
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);
}
}
}
关于c# - 从类中调用 double ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22373396/