What\'s the simplest way to perform a set subtraction given two arrays in C#? Apparently this is dead easy in Ruby. Basically I just want to remove the elements from array <
If you're using Linq, you can use the Except operator like this:
string [] c = a.Except(b).ToArray();
Edit: CodeInChaos makes a good point. If a
contains duplicates, it will remove any duplicates as well. The alternative to make it function exactly like the Ruby version would be this:
string [] c = a.Where(x=>!b.Contains(x)).ToArray();