例如有十个同一类的产品,产品分别都有长、宽、高三个属性,我想分别定义为三个属性列表来表示产品的这三个属性,请问该怎样实现呢??

解决方案 »

  1.   

    在delphi中有记录类型,在c#中是不是用类啊? 俺是c#初学者
      

  2.   

    public class MyProduct
    {
    private int _myHeight;
    private int _myWidth;
    private int _myLength; public int MyHeight
    {
    get {return _myHeight;}
    set {_myHeight = value;}
    } public int MyWidth
    {
    get {return _myWidth;}
    set {_myWidth = value;}
    } public int MyLength
    {
    get {return _myLength;}
    set {_myLength = value;}
    }

    } public class MyMain
    {
    public void test()
    {
    MyProduct p1 = new MyProduct();
    p1.MyWidth = 50;
    p1.MyLength = 200;
    p1.MyHeight = 20;
    }
    }