C#中如何定义全局的数组变量

解决方案 »

  1.   

    public class A
    {
       public static int[] item;
    }A.item[0]
    A.item[1]
      

  2.   

    自然是有必要的。  //class myclass 要加public及static才能在Form1中访问
      public static class myclass
      {
        public string strTest;
      }
      public class Form1 : System.Windows.Forms.Form
      {
        //访问全局变量
        console.WriteLine(myclass.strTest);
        myclass.strTest="This is a global string in myclass";
      }
      

  3.   

    同意楼上,也可以
     public static  string strTest;