ExtensionMethod.NET Home of 829 C#, Visual Basic, F# and Javascript extension methods


Clones a DataRow - including strongly typed DataRows.


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


MyDataRow newDataRow = myDataRow.Clone<MyDataRow>(myDataRow.DataTable);

Author: Robert M. Downey

Submitted on: 18 okt 2010

Language: C#

Type: System.Data.DataRow

Views: 5525