.net 2.0 - in c# I would like to compare datatables -
i compare 2 datatables. need know contents different yes or no. can 1 recommend quick way compare them?
i know if contents (data) diffrent
assuming tables have same structure (column names , data types)
static bool aretablesequal(datatable t1, datatable t2) { // if number of rows different, no need compare data if (t1.rows.count != t2.rows.count) return false; (int = 0; < t1.rows.count; i++) { foreach(datacolumn col in t1.columns) { if (!equals(t1.rows[i][col.columnname], t2.rows[i][col.columnname])) return false; } } return true; }
Comments
Post a Comment