C# SortedSet ExceptWith
Description
SortedSet
removes all elements that
are in a specified collection from the current SortedSet
Syntax
SortedSet.ExceptWith
has the following syntax.
public void ExceptWith(
IEnumerable<T> other
)
Parameters
SortedSet.ExceptWith
has the following parameters.
other
- The collection of items to remove from the SortedSetobject.
Example
using System;/*from www . j a va2s . com*/
using System.Collections;
using System.Collections.Generic;
using System.IO;
class Program
{
static void Main(string[] args)
{
SortedSet<string> set1 = new SortedSet<string>();
set1.Add("a");
set1.Add("b");
set1.Add("d");
set1.Add("d");
SortedSet<string> set2 = new SortedSet<string>();
set2.Add("a");
set2.Add("b");
set2.Add("c");
set2.Add("d");
set1.ExceptWith(set2);
foreach (string s in set1)
{
Console.WriteLine(s);
}
}
}