Clone<T>
Clones a DataRow - including strongly typed DataRows.
Source
/// <summary>
/// Creates a cloned and detached copy of a DataRow instance
/// </summary>
/// <typeparam name="T">The type of the DataRow if strongly typed</typeparam>
/// <returns>
/// An instance of the new DataRow
/// </returns>
public static T Clone<T>(this DataRow dataRow, DataTable parentTable)
where T : DataRow
{
T clonedRow = (T)parentTable.NewRow();
clonedRow.ItemArray = dataRow.ItemArray;
return clonedRow;
}
Example
MyDataRow newDataRow = myDataRow.Clone<MyDataRow>(myDataRow.DataTable);
Author: Robert M. Downey
Submitted on: 18 okt. 2010
Language: C#
Type: System.Data.DataRow
Views: 7857