1

I have two lists:

List<int> data1 = new List<int> {1,2};
List<int> data2 = new List<int>{1,2,3,4};

I want to create a new list:

List<int> data3

which intersects data1 and data2 and and contains elements as {3,4}

D-Shih
  • 44,943
  • 6
  • 31
  • 51
Mr.Curious
  • 282
  • 1
  • 3
  • 11

1 Answers1

3

You can try to use Except

var result = data2.Except(data1);

c# online

D-Shih
  • 44,943
  • 6
  • 31
  • 51