#region 根据datatable获得列名 public static string[] GetColumnsByDataTable(DataTable dt) /// <summary> /// 根据datatable获得列名 /// </summary> /// <param name="dt">表对象</param> /// <returns>返回结果的数据列数组</returns> public static string[] GetColumnsByDataTable(DataTable dt) { string[] strColumns = null; if (dt.Columns.Count > 0) { int columnNum = 0; columnNum = dt.Columns.Count; strColumns = new string[columnNum]; for (int i = 0; i < dt.Columns.Count; i++) { strColumns[i] = dt.Columns[i].ColumnName; } } return strColumns; } #endregion