【发布时间】:2020-04-13 10:42:34
【问题描述】:
我想知道如何在稍后的方法中使用全局变量——我已经将它实例化为公共整数类型。
到目前为止,这是我的代码:
public int money = 500000;
//other variables
//...some code in between
public static void UpdateResources (int cost, int airRate, int waterRate, int foodRate, int energyRate, int maintenanceRate, int happinessRate)
{
// \/ Problem here
if (money < cost)
{
//uncheck box
}
else
{
//implement input variables with other external variables
}
}
【问题讨论】:
-
也让它成为静态的。
标签: c# variables methods public