Ive seen example of :
int[] a1 = { 1, 2, 3 };
int[] b1 = { 1, 2, 3 };
a1.Equals(b1) //false
a1.Equals(b1,EqualityComparer<int>.Default)); //true
However I cant get the overloaded method as you see...
what am i missing ?
There's no such method on System.Object
(or any other type that would allow such use on an array of ints).
I think you're looking for Enumerable.SequenceEqual
method, an extension-method from LINQ to Objects:
a1.SequenceEqual(b1, EqualityComparer<int>.Default)
although you might as well equivalently do:
a1.SequenceEqual(b1)
EDIT: If you want to use the Equals
method from IStructuralEquatable
, you'll have to cast to the interface since arrays implement this interface explictly:
((IStructuralEquatable)a1).Equals(b1, EqualityComparer<int>.Default)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With