I have two List<string>
that contain huge data, and I have the following code which I used till now. But I have some doubts regarding this, due to lot of confusion about the data is compared or not in the list items. Here I am using sequence Equal
to compare the data. I have two questions. Somewhere I found that SequenceEqual
will compare the data in the lists. So used it.
Will
SequenceEqual
compares the data in the lists?Better way of code to improve performance. As per understanding I kept only three items in both the lists but our requirement has huge data items in the lists. So need to improve performance.
bool value = false; List<string> list1 = new List<string>(); list1.Add("one"); list1.Add("two"); list1.Add("three"); List<string> list2 = new List<string>(); list2.Add("one"); list2.Add("two"); list2.Add("three"); list1.Sort(); list2.Sort(); if (list1.SequenceEqual(list2)) { value = true; } else { value = false; } return value;