C#中实例一个自定义类的数组的做法

来源:互联网 发布:腾讯数据分析工程师 编辑:程序博客网 时间:2024/04/27 22:46
/类
public class BarChartValue
{
    public BarChartValue()
    {

    }
    public BarChartValue(string MyName, int Myvalue)
    {
        Name = MyName;
        MValue = Myvalue;
    }
    private string name;
    public string Name
    {
        get
        {
            return name;
        }
        set
        {
            name = value;
        }
    }

    private int mvalue;
    public int MValue
    {
        get
        {
            return mvalue;
        }
        set
        {
            mvalue = value;
        }
    }
}

1.
        BarChartValue[] BarChartValue ={
        new BarChartValue("第一个仓库",1),
        new BarChartValue("第一个仓库",2)
        };
2.

        BarChartValue[] BarChartValue= new BarChartValue[2];
        BarChartValue[0] = new mytest();
        BarChartValue[0].Name = "";
        BarChartValue[1] = new mytest();
        BarChartValue[1].Name = "";
3.
        for (int i = 0; i < 5; i++)
        {
            BarChartValue[i] = new BarChartValue();
            BarChartValue[i].Name = "";
        }

用法:
用方法 :
Render("BarChartValue);
方法:
public string Render(PieChartValue[] Mydata)

原创粉丝点击