You're comparing the object references, and they are not the same. You need to compare the array contents.
An option is iterating through the array elements and call Equals()
for each element. Remember that you need to override the Equals()
method for the array elements, if they are not the same object reference.
An alternative is using this generic method to compare two generic arrays:
static bool ArraysEqual<T>(T[] a1, T[] a2)
{
if (ReferenceEquals(a1, a2))
return true;
if (a1 == null || a2 == null)
return false;
if (a1.Length != a2.Length)
return false;
var comparer = EqualityComparer<T>.Default;
for (int i = 0; i < a1.Length; i++)
{
if (!comparer.Equals(a1[i], a2[i])) return false;
}
return true;
}
Or use SequenceEqual if Linq is available for you (.NET Framework >= 3.5)