The two lists are like
LISTONE "ONE", "TWO", "THREE"
LISTTWO "ONE", "TWO", "THREE"
i need to compare the whether the items in two lists are in same order or not.
Is there any way to do this in LINQ
The two lists are like
LISTONE "ONE", "TWO", "THREE"
LISTTWO "ONE", "TWO", "THREE"
i need to compare the whether the items in two lists are in same order or not.
Is there any way to do this in LINQ
Maybe:
bool equal = collection1.SequenceEqual(collection2);
See also: Comparing two collections for equality irrespective of the order of items in them
OrderBy calls would mean that the order was ignored: but Pramodh wants to see if they are in the same orderDetermine if both lists contain the same data in same order:
bool result = list1.SequenceEqual(list2);
Same entries in different order:
bool result = list1.Intersect(list2).Count() == list1.Count;
Intersect method uses set intersection, so you might get unexpected results if one or both of the lists contain duplicates.