c# dataTable 合并两个列到一个新列中
public static DataTable UniteDataTableColumns(DataTable dt, String newColumnName, string ColumnName1, string ColumnName2) { //汇总的表达式 string expression = ""; expression = String.Format("{0}+'('+{1}+')'", ColumnName1, ColumnName2); //增加汇总列 System.Type myDataType = System.Type.GetType("System.String"); DataColumn dcCol = new DataColumn(newColumnName, myDataType, expression, MappingType.Attribute); //增加合并列 dt.Columns.Add(dcCol); return dt; }
posted on 2013-10-09 09:17 AlexGeng 阅读(10547) 评论(0) 编辑 收藏 举报