对,没有全局变量这个概念了
一般的做法是把全局变量全部封装到一个类中,使用static就可以了。
各位高手有什么意见
public class GVar { public static string szName = " "; public static int nAge = 0; } // 在这个类里面使用GVar类中的变量 public class MyForm : System.Windows.Forms { ... public void fun() { // 这里相当于使用全局变量(其他地方用法也一样) GVar.szName = "Bill "; GVar.nAge = 10; } }