public class MonthEntity
{
public int monthid { get; set; }
public string Date_01_01_2016 { get; set; }
public string Date_02_01_2016 { get; set; }
public string Date_03_01_2016 { get; set; }
public string Date_04_01_2016 { get; set; }
public string Date_05_01_2016 { get; set; }
}
但使用代码如create
List<MonthEntity> list=new List<MonthEntity>();
动态添加像DataTable这样的对象创建列
DataTable dt=new DataTable();
string[] cols={"01","02",.....All any month dates};
foreach(string s in cols)
{
dt.Columns.Add(s);
}
像数据表一样,我想用动态列创建列表.....
答案 0 :(得分:0)
您可以像这样构建您的实体:
public class MonthEntity
{
public int monthid { get; set; }
public Dictionary<string, string> TheDate { get; set; }
}
然后将每个日期作为条目添加到字典字段