日期:2014-05-17  浏览次数:20464 次

建自定义类问题,如何在一个类中建立3个不同的二维数组
我需要封装一个类,在里面有3个不限长度的二维数组,结构如下
public class TableFormwork
{
public string[][] Title;
public int[][] RowSpan;
public int[][] ColumnSpan;
public TableFormwork(){}// 构造函数
}

要录入的数据如下:
// 表头设定
string[][] head_string = {
new string[]{"序号","队别","井号","堵水时间","堵水前生产情况","堵水初期生产情况","目前生产情况","累计降液","累计降水","累计增油","有效期(d)","备注",},
new string[]{
"产液(t/d)","产油(t/d)","含水(%)","动液面(m)","沉没度(m)",
"产液(t/d)","产油(t/d)","含水(%)","动液面(m)","沉没度(m)",
"产液(t/d)","产油(t/d)","含水(%)","动液面(m)","沉没度(m)"
}
};
int[][] head_rowspan = {
new int[]{2,2,2,2,1,1,1,2,2,2,2,2},
new int[]{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
};
int[][] head_colspan = {
new int[]{1,1,1,1,5,5,5,1,1,1,1,1},
new int[]{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
};

我该怎么写构造函数,尝试了很多办法都不行,
asp.net 二维数组

------解决方案--------------------
public class TableFormwork
{
// 类内部变量
private string cTitle;
private int cStartRow;
private string[][] cText;
private int[][] cRowSpan;
private int[][] cColumnSpan;

// 类变量赋值
public string[][] Title {
          get { return this.cTitle; }
          set { this.cTitle = value; } 
}
public string[][] StartRow {
          get { return this.cStartRow; }
          set { this.cStartRow = value; } 
}
public string[][] Text {
          get { return this.cText; }
          set { this.cText = value; } 
}
public int[][] RowSpan {
          get { return this.cRowSpan; }
          set { this.cRowSpan = value; } 
}
public int[][] ColumnSpan {
          get { return this.cColumnSpan; }
          set { this.cColumnSpan = value; } 
}

// 构造函数
public TableFormwork(){}
public TableFormwork(string title, int startrow, string[][] text, int[][] rowspan, int[][] columnspan)
{
this.Title = title;
this.StartRow = startrow;
this.Text = text;
this.RowSpan = rowspan;
this.ColumnSpan = columnspan;
}
}