DataTableRowsAdd
The method DataTable.Rows.Add() adds a new row to the end of the DataTable.
Syntax:
DataTable.Rows.Add(params object[] values);
where,
params object[] values- represents an array of values to be added as a new row to the DataTable.
Example:
DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Age", typeof(int));
dt.Rows.Add(1, "John", 25);
dt.Rows.Add(2, "Jane", 30);
In the above example, we create a new DataTable with three columns: ID, Name and Age. Then, we add two rows to the DataTable using the Rows.Add() method. The first row contains values 1, "John" and 25 for ID, Name and Age columns respectively. The second row contains values 2, "Jane" and 30 for ID, Name and Age columns respectively.
原文地址: http://www.cveoy.top/t/topic/KVt 著作权归作者所有。请勿转载和采集!