时间:2010-07-06 18:54:26

标签: c# class-library

****下面是我的winform client inst,在类中有一个参数构造函数。****

    private void button1_Click(object sender, EventArgs e)
    {

        string s1 = textBox1.Text;
        int x1 =  Convert.ToInt32(s1);
        int X= x1;        
       ExternalTest ob =  new ExternalTest(X);                 
       string s2 = Convert.ToString(ob.Y);              
        ob.Y = 0;
       textBox2.Text = s2;

以下是我加入项目的课程 下面的代码是程序集中添加的类。如果我试图使它成为一个类库并添加addreference - 它将无法构建。

class ExternalTest       
{      
            private int _x;
       //     protected new int x
       //     {
       //        get { return _x; }
       //        set  {_x = value ;}
       //     }
             private int y;
             public  int Y 
            {                 
              get {return y =  Mult(_x); }
              set { }
            }        
                internal   int Mult(int _x)
              {                       
              y = _x + 51;   
               return  y;         
               }    

            public ExternalTest(int X)
           {
               _x =  X;             

           }            

      }
}

1 个答案:

答案 0 :(得分:1)