In this article we are going to the usage of SequenceEqual method. Let we see the example how it is works.
/*Find
the equal of two sequence */
var
seq1 = new List<int>() {1,6,3,21};
var
seq2 = new List<int>() {4,6,21,3,5};
var
seq3 = new List<int>() { 3, 6, 21, 1 };
var
seq4 = new List<int>() { 1, 6, 3, 21 };
Console.WriteLine(seq1.SequenceEqual(seq2));
Output:
False
The output for the above code is false, because the values present in seq1 and seq2 is different.
Console.WriteLine(seq1.SequenceEqual(seq3));
Output:
False
The output for the above code is false, because the values present in seq1 and seq3 is same but are in different sequence.
Console.WriteLine(seq1.SequenceEqual(seq4));
Output:
True
The output for the above code is True, because the values present in seq1 and seq4 is same and also in sequence.
From this article you can learn the usage of SequenceEqual in Linq.
No comments:
Post a Comment