Sets operations in C#
Forums:
var first = new HashSet<int> { 1, 2, 3 };
var second = new HashSet<int> { 3, 4, 5 };
first.UnionWith(second);
//first is { 1, 2, 3, 4, 5 }
first.ExceptWith(second);
//first is { 1, 2 }
first.IntersectWith(second);
//first is { 3 }
first.SymmetricExceptWith(second);
//first is { 1, 2, 4, 5 }
- Log in to post comments