I am trying to compare two .NET arrays. Here is an obvious implementation for comparing arrays of bytes:
bool AreEqual(byte[] a, byte[] b){
if(a.Length !
With the advent of .NET 4 you can use the method Equals() being provided by .NET arrays' explicitly implemented interface IStructuralEquatable. Then the code might look like this (I rewrote CMS' example):
string[] a = { "1", "2", "3" };
string[] b = { "1", "2", "3" };
bool result = ((IStructuralEquatable)a).Equals(b, StructuralComparisons.StructuralEqualityComparer);
// result evaluates to true.
(IStructuralEquatable is also implemented in Tuples (also new in .NET 4).)