There are two files. I read from them both values in the lists. I want to take unique values from both lists, however, the process of searching and comparing is very long (there are ~ 300k lines in both lists). Tell me how to speed up the process of searching and comparing *?
var lst1 = File.ReadAllLines(@ "D:\test\1.csv").ToList(); var lst2 = File.ReadAllLines(@ "D:\\test\2.csv").ToList(); var rez = lst2.Where(x => !MySequenceContains(lst1, x)). Select(q => string.Join(";", q)).ToList(); } private bool MySequenceContains(List < string > x, string y) { bool contains = false; index++; label2.Text = index.ToString(); foreach(var a in x) { // ToDo: tweak the string comparison as needed if (string.Compare(a.Split(';')[0], y.Split(';')[0], StringComparison.InvariantCultureIgnoreCase) == 0 && string.Compare(a.Split(';')[14], y.Split(';')[14], StringComparison.InvariantCultureIgnoreCase) == 0) { contains = true; break; } } return contains; }