Clone<T>

/// <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);

Description

Clones a DataRow - including strongly typed DataRows.

Details

Double click on the code to select all.

 

;