1 /// <summary> 2 /// 获取DataTable中指定列的数据 3 /// </summary> 4 /// <param name="dt">数据源</param> 5 /// <param name="tableName">新的DataTable的名词</param> 6 /// <param name="strColumns">指定的列名集合</param> 7 /// <returns>返回新的DataTable</returns> 8 public static DataTable GetTableColumn(DataTable dt, string tableName, params string[] strColumns) 9 { 10 DataTable dtn = new DataTable(); 11 if (dt == null) 12 { 13 throw new ArgumentNullException("参数dt不能为null"); 14 } 15 try 16 { 17 dtn = dt.DefaultView.ToTable(tableName, true, strColumns); 18 } 19 catch (Exception e) 20 { 21 throw new Exception(e.Message); 22 } 23 return dtn; 24 }