Home >Backend Development >C#.Net Tutorial >C# DataTable Usage Summary
1. Create a new table
private DataTable vsDt =new DataTable();
2. Clear the contents of the table (the columns in the table are still there)
vsDt.Clear();
3. Clear the columns of the table
vsDt.Columns.Clear();
4. Add columns to the table
vsDt.Columns.Add("BH", typeof(string)); vsDt.Columns.Add("RQ", typeof(string));
5. Add empty rows to the table
DataRow vsDr = vsDt.NewRow();
If you have gone before adding a blank row N columns have been added to the table, so the newly added empty rows will also have these columns.
6. Add rows to the table
vsDt.Rows.Add(vsDr);
The above is the summary of C# DataTable usage. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!