Forums - C# Corner

Forum guidelines
Deer Park

Deer Park

  • 0
  • 39
  • 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)

techbash 2016

SPONSORED BY

C# Corner Chandigarh DevCon16
Chandigarh DevCon16 is a one-day Developer Conference where programmers, technologists, authors, and members meet, demonstrate, plan, and hang out.