0
List<String> A = new List<String>();
List<String> B = new List<String>();
List<String> itemsremoved = ((A∩B)^c)-A;
List<String> itemsadded = ((A∩B)^c)-B;

I want to know how to do a complement of the union A & B minus the elements of a list. Is there a function to do this?

sheepiiHD
  • 421
  • 2
  • 16

1 Answers1

2

LINQ provides extension methods for working with sets.

For example, the complement of set a relative to set b will be:

var a = new List<int> { 1, 2, 3, 6 };
var b = new List<int> { 3, 4, 5, 6 };

var comp = a.Except(b);

comp will contain elements [1, 2].

Do a Google search for C# and LINQ set operations and you're sure to find plenty of examples.

easuter
  • 1,167
  • 14
  • 20