Checking equality on unordered lists can be done with Intersect, but how would you compare ordered lists with LINQ? The expression should return true if both sequences have the same elements in the same order.
Thanks
a.SequenceEqual(b);
From the documentation:
Returns true if the two source sequences are of equal length and their corresponding elements are equal according to the default equality comparer for their type; otherwise, false.
See MSDN for more.
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