NSSet mySet = new NSSet(new string[] {"Apple", "Orange", "Banana"}); mySet.Add("Mango"); mySet.Add("Apple"); // this will not add a duplicate element
NSSet setA = new NSSet(new int[] {1, 2, 3}); NSSet setB = new NSSet(new int[] {2, 3, 4}); NSSet union = new NSSet(setA.Union(setB).ToArray()); NSSet intersection = new NSSet(setA.Intersect(setB).ToArray()); NSSet difference = new NSSet(setA.Except(setB).ToArray());The above code creates two sets (setA and setB) and performs union, intersection, and difference operations on them using LINQ. The resulting NSSet objects (union, intersection, and difference) contain the desired elements. Package library: MonoTouch.Foundation.