Forums - C# Corner

Forum guidelines
Deer Park

Deer Park

  • 0
  • 0
  • 0

Excluding value on one list from other list-Taking too long

Dec 2 2012 2:32 PM
So, I have two list of int array. 
Say result1 and result2. I am using the code as follow which will exclude all the items that are in result2 from result1. 
But it's talking too much time, since I have thousands of item on both list of int array. Is there any other approach with which I can achieve same efficiently? Appreciated!!



List result1 = new List { new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 } };
List result2 = new List { new int[] { 1, 2, 3 }, new int[] { 7, 8, 9 } };

result2.ForEach(t => result1.RemoveAll(z => z.OrderBy(k=>k).SequenceEqual(t.OrderBy(k=>k))));



Answers (8)

C# Corner Hyderabad Developer Conference

SPONSORED BY

Spire.Doc - Free .NET Word API
Use Spire.Doc to create, read, write, print, and convert word documents to OpenXML, RTF, TXT, XPS, EPUB, EMF, HTML, Image and PDF.