1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
/// <summary>
/// DataTableの比較を行います。
/// </summary>
/// <param name="dt1"> DataTable1</param>
/// <param name="dt2"> DataTable2</param>
/// < returns> true:同じ false:異なる</returns>
public static bool DataTableCompare(DataTable dt1, DataTable dt2)
{
if (dt1 == null && dt2 != null) { return false; }
if (dt1 != null && dt2 == null) { return false; }
if (dt1 == null && dt2 == null) { return true; }
if (dt1.Rows.Count != dt2.Rows.Count) { return false; }
for (int row = 0; row < dt2.Rows.Count; row++)
{
for (int col = 0; col < dt2.Columns.Count; col++)
{
if (!dt1.Rows[row][col].Equals(dt2.Rows[row][col]))
{
return false;
}
}
}
return true;
}
|