27/4/11

Comparar el contenido de dos filas

public static bool ContenidoRowsEsIgual<T>(T row1, T row2) where T : DataRow {
bool result = true;
if (!row1.GetType().Equals(row2.GetType())) {
throw new Exception("Las filas no son del mismo tipo");
}
DataRow r1 = row1 as DataRow;
DataRow r2 = row2 as DataRow;
for (int i = 0; i < r1.ItemArray.Length; i++) {
if (!r1[i].Equals(r2[i])) {
result = false;
}
}
return result;
}