C# 自定义泛型集合
C#自定义集合定义个实体类Cells字段publicclassCells{privateintcellNo;publicintCellNo{get{returncellN...
C# 自定义集合
定义个实体类 Cells 字段
public class Cells
{
private int cellNo;
public int CellNo
{
get { return cellNo; }
set { cellNo = value; }
}
private string cellData;
public string CellData
{
get { return cellData; }
set { cellData = value; }
}
}
一个Rows<Cells> 泛型集合类 怎么写
因为我要这样使用
Cells c=new Cells();
Rows<Cells> r=new Rows<Cells>();
r.add(c);
List<Rows<Cells>> list = new List<Rows<Cells>>();
list.add(r); 展开
定义个实体类 Cells 字段
public class Cells
{
private int cellNo;
public int CellNo
{
get { return cellNo; }
set { cellNo = value; }
}
private string cellData;
public string CellData
{
get { return cellData; }
set { cellData = value; }
}
}
一个Rows<Cells> 泛型集合类 怎么写
因为我要这样使用
Cells c=new Cells();
Rows<Cells> r=new Rows<Cells>();
r.add(c);
List<Rows<Cells>> list = new List<Rows<Cells>>();
list.add(r); 展开
2个回答
展开全部
class Program
{
static void Main(string[] args)
{
Cells c = new Cells();
Rows<Cells> r = new Rows<Cells>();
r.Add(c);
List<Rows<Cells>> list = new List<Rows<Cells>>();
list.Add(r);
}
}
public class Cells
{
private int cellNo;
public int CellNo
{
get { return cellNo; }
set { cellNo = value; }
}
private string cellData;
public string CellData
{
get { return cellData; }
set { cellData = value; }
}
}
public class Rows<T>
{
private int rowNo;
public int RowNo
{
get { return rowNo; }
set { rowNo = value; }
}
private T rowData;
public T RowData
{
get { return rowData; }
set { rowData = value; }
}
public void Add(T cell)
{
rowData = cell;
}
}
{
static void Main(string[] args)
{
Cells c = new Cells();
Rows<Cells> r = new Rows<Cells>();
r.Add(c);
List<Rows<Cells>> list = new List<Rows<Cells>>();
list.Add(r);
}
}
public class Cells
{
private int cellNo;
public int CellNo
{
get { return cellNo; }
set { cellNo = value; }
}
private string cellData;
public string CellData
{
get { return cellData; }
set { cellData = value; }
}
}
public class Rows<T>
{
private int rowNo;
public int RowNo
{
get { return rowNo; }
set { rowNo = value; }
}
private T rowData;
public T RowData
{
get { return rowData; }
set { rowData = value; }
}
public void Add(T cell)
{
rowData = cell;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询