// List<FieldModelBase> 转 DataTable private DataTable ListToDataTable(List<FieldModelBase> f) { var dt = new DataTable(); //创建列 foreach (FieldModelInfo v in f[0]) { dt.Columns.Add(v.Fieldname); } //遍历集合list foreach (FieldModelBase c in f) { //行数据 ArrayList tempList = new ArrayList(); //遍历每对键值 foreach (FieldModelInfo v in c) { tempList.Add(v.Fieldvalue); } object[] array = tempList.ToArray(); dt.LoadDataRow(array, true); } return dt; }