Skip to content

Instantly share code, notes, and snippets.

@stephensmitchell
Forked from meklarian/string-set-vs-set.cs
Last active April 19, 2018 01:00
Show Gist options
  • Save stephensmitchell/5a9a7bd98d530a0fc1c4bfa78705d34d to your computer and use it in GitHub Desktop.
Save stephensmitchell/5a9a7bd98d530a0fc1c4bfa78705d34d to your computer and use it in GitHub Desktop.
LINQPad snippet that declares two string arrays, spits out their mutually exclusive parts. #LINQPad
var set1 = new string[]{"a","b","c","d"};
var set2 = new string[]{"a","e","i","o","u"};
var q = set1.Except(set2);
Console.WriteLine(q.Count());
Console.WriteLine("");
foreach(string s in q)
{
Console.WriteLine(s);
}
Console.WriteLine("");
var r = set2.Except(set1);
Console.WriteLine(r.Count());
Console.WriteLine("");
foreach(string s in r)
{
Console.WriteLine(s);
}
Console.WriteLine("");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment