Easiest way to compare arrays in C#
Also for arrays (and tuples) you can use new interfaces from .NET 4.0: IStructuralComparable and IStructuralEquatable. Using them you can not only check equality of arrays but also compare them.
static class StructuralExtensions{ public static bool StructuralEquals<T>(this T a, T b) where T : IStructuralEquatable { return a.Equals(b, StructuralComparisons.StructuralEqualityComparer); } public static int StructuralCompare<T>(this T a, T b) where T : IStructuralComparable { return a.CompareTo(b, StructuralComparisons.StructuralComparer); }}{ var a = new[] { 1, 2, 3 }; var b = new[] { 1, 2, 3 }; Console.WriteLine(a.Equals(b)); // False Console.WriteLine(a.StructuralEquals(b)); // True}{ var a = new[] { 1, 3, 3 }; var b = new[] { 1, 2, 3 }; Console.WriteLine(a.StructuralCompare(b)); // 1}