由于 Main是一个static method,所以,
在代码中不可以出现this.
this代表类的某个具体实例。

解决方案 »

  1.   

    试试看这样public static void Main(){x=6;
    this_class tc=new this_class();
    tc.x=1234;
    Console.WriteLine("x= {0}",x);
    Console.WriteLine("tc.x= {0}",tc.x); 
    }
      

  2.   

    using System;
    class this_class{
        public static int x; 
    public static void Main(){x=6;
    Console.WriteLine("x= {0}",x);
    Console.WriteLine("this.x= {0}",this_class.x); 
    }
    }
    x是static变量,使用是是类名.变量名, 不是事例名.变量名.
      

  3.   

    我从你们的解答分析一下:
      如果x是一个static变量,在main()里,用类名.x 来调用
      如果x是一个普通的在main()外定义的变量,在main()里需要实例化 事例名.变量名
      如果x是一个普通的在main()里定义的变量,在main()里可直接调用