C#中没有全局变量的概念,可以定义一个common类,通过静态变量来存放所有需要的全局变量,调用的时候通过common来调用即可。
public static class common // static 不是必须 { public static float [ , ] farray = new float [ 2, 3]; private static string name = "cc"; public static string Name { get { return name;} set { name = value;} } }
调用的时候使用“命名空间.common.属性名”即可,例如
原文:http://www.cnblogs.com/China3S/p/5179808.html