#region 判断两个DataTable是否相同
/// <summary>
/// 判断两个DataTable是否相同
/// </summary>
/// <param name="Table1">表1</param>
/// <param name="Table2">表2</param>
/// <returns></returns>
public bool DataTableTheSame(DataTable Table1, DataTable Table2)
{
if (Table1 == null || Table2 == null)
{
return false;
}
if (Table1.Rows.Count != Table2.Rows.Count)
{
return false;
}
if (Table1.Columns.Count != Table2.Columns.Count)
{
return false;
}
for (int i = 0; i < Table1.Rows.Count; i++)
{
for (int j = 0; j < Table1.Columns.Count; j++)
{
if (Table1.Rows[i][j].ToString() != Table2.Rows[i][j].ToString())
{
return false;
}
}
}
return true;
}
#endregion
#region 判断两个List是否相同
/// <summary>
/// 判断两个List是否相同
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="ListA">对象A</param>
/// <param name="ListB">对象B</param>
/// <returns></returns>
public bool IsEqual<T>(IList<T> ListA, IList<T> ListB)
{
if (ListA.Count != ListB.Count)
{
return false;
}
else
{
foreach (var item in ListA)
{
if (!ListB.Contains(item))
{
return false;
}
}
return true;
}
}
#endregion
转载于:https://my.oschina.net/u/2446847/blog/1826405