static string a = "1";

解决方案 »

  1.   

    不申明为static 就没有初始化a
      

  2.   

    那每个声明的字段都要声明为static吗?
      

  3.   

    public Test(){init..
    }
      

  4.   

    共享方法是不能访问实例变量的。想想看,所有Test类的对象都有一个a,但只有一个Main,它怎么能决定显示哪一个a呢?
      

  5.   

    类的成员要么属于类,要么属于实例!
    可以这样访问类成员:
    第一种方法:变量a设为静态的
       static string a="1";
    第二种方法:创建实例
       Test myTest=new Test();
       Console.WriteLine(myTest.a);
    你看,他都明白了,你明白了吗?明白了请给分!