IsEquality
/// <summary>
/// 通用比较器
/// </summary>
/// <typeparam name="T">可比较的对象类型</typeparam>
public static class Comparar<T> where T : IComparable
{
/// <summary>
/// 比较是否相等
/// </summary>
/// <param name="t1"></param>
/// <param name="t2"></param>
/// <returns></returns>
public static bool IsEquality(T t1, T t2)
{
if (t1.CompareTo(t2) == 0)
{
return true;
}
return false;
}
}
CompararArray
public static bool CompararArray(T[] arr1, T[] arr2)
{
if (arr1.Length != arr2.Length)
{
return false;
}
for (int i = 0; i < arr1.Length; i++)
{
if (!IsEquality(arr1[i], arr2[i]))
{
return false;
}
}
return true;
}