Suppose we have Two Integer List and they are:
Now we want to know that two list sequence and value are same or not. Then our code will be,
And our output will be,
False
Lets, do another. Now we have two list that have same value but their order is not same.
And our output will be,
False
Ok, Lets do one more. Now we have two list and their order and value is same and see what will be the result.
And the output is
True
Now do the final experiment. Now we have two list and their order and value is same but first list length is greater than the second.
And the result is,
False
var numberList1 = new List<int> { 3, 4, 5, 6, 7 };
var numberList2 = new List<int> { 21, 3, 5, 23, 4 };
Now we want to know that two list sequence and value are same or not. Then our code will be,
var numberList1 = new List<int> { 3, 4, 5, 6, 7 };
var numberList2 = new List<int> { 21, 3, 5, 23, 4 };
var isEqual = numberList1.SequenceEqual(numberList2);
Console.WriteLine(isEqual);
And our output will be,
False
Lets, do another. Now we have two list that have same value but their order is not same.
var numberList1 = new List<int> { 3, 4, 5};
var numberList2 = new List<int> { 5, 4, 3};
var isEqual = numberList1.SequenceEqual(numberList2);
Console.WriteLine(isEqual);
And our output will be,
False
Ok, Lets do one more. Now we have two list and their order and value is same and see what will be the result.
var numberList1 = new List<int> { 3, 4, 5 };
var numberList2 = new List<int> { 3, 4, 5 };
var isEqual = numberList1.SequenceEqual(numberList2);
Console.WriteLine(isEqual);
And the output is
True
Now do the final experiment. Now we have two list and their order and value is same but first list length is greater than the second.
var numberList1 = new List<int> { 3, 4, 5, 7 };
var numberList2 = new List<int> { 3, 4, 5 };
var isEqual = numberList1.SequenceEqual(numberList2);
Console.WriteLine(isEqual);
And the result is,
False
No comments:
Post a Comment