lass Program
    {
        protected int x = 10;
        protected  int y = x*2;
        
         public static void Main(string[] args)
        {
            Program text = new Program();
            Console.WriteLine("{0},{1}", text.x, text.y);
        }
    }

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data.OleDb;
    using System.Data;
    class Program
      {
          protected int x = 10;
          protected int y = 10*2;
            
          public static void Main(string[] args)
          {
              Program text = new Program();
              Console.WriteLine("{0},{1}", text.x, text.y);
          }
      }
      

  2.   

    lass   这个是什么??
      

  3.   

    lass Program
      {
      

  4.   

    class
      

  5.   

    对y的赋值(因为涉及到x),所以应该放到构造函数里。对类成员的赋值必须是静态的表达式。protected int x;
    protected int y;public void Program()
    {
        x = 10;
        y = x * 2;
    }