[Reserved] C # Gets all the column names by traversing the DataTable column

During operation Datatable data variables in C #, it is possible to obtain all the column name information in the DataTable by all columns objects Columns property to traverse the DataTable, DataTable objects in all columns are stored in Columns property of the DataTable, including column name, column data type of data stored, and so on.

C # DataTable to traverse to get all the column names of the program statement as follows:

List <String> = columnNameList new new List <String> (); 
 the foreach (DataColumn in dataDt.Columns COL) 
{ 
        columnNameList.Add (col.ColumnName); // acquired DataColumn object column name column 
}

  

Note: The text reproduced from personal bloggers station IT technology small fun house , the original link for the C # Gets all the column names _IT technology small fun house by walking DataTable column .

Bloggers personal technology exchange group: 960 640 092, blogger micro-channel public numbers are as follows:

Guess you like

Origin www.cnblogs.com/xu-yi/p/11246414.html