Mega Code Archive

 
Categories / C# Book / 03 Collections
 

0363 Set operation SymmetricExceptWith

SymmetricExceptWith removes all but the elements that are unique to one set or the other. using System; using System.Collections; using System.Collections.Generic; using System.Linq; class Sample { public static void Main() { var letters = new HashSet<char>("the quick brown fox"); letters.SymmetricExceptWith("the lazy brown fox"); foreach (char c in letters) Console.Write(c); } } The output: quicklazy