How do you compare two sequences using LINQ? The answer is by using the Enumerable.SequenceEqual(). SequenceEqual() compares the source and target sequences elements, by using the default equality comparer for their type, and returns a Boolean.
There are many ways to use the SequenceEqual() extension method – like to compare the files in two folders and see if they contain the same files. Let us see a simple example of using the SequenceEqual() extension method
The output will be: False
Now what if you want to find out the difference between these two sequences?. Use this piece of code which uses the IEnumerable.Except extension method:
OUTPUT
Tweet
1 comment:
Hi, interesting article, but I have a question: what if you do l2.Except(l1) ?
Thanks
Post a Comment