C# HashSet SymmetricExceptWith
Description
HashSet
modifies the current
HashSet
Syntax
HashSet.SymmetricExceptWith
has the following syntax.
public void SymmetricExceptWith(
IEnumerable<T> other
)
Parameters
HashSet.SymmetricExceptWith
has the following parameters.
other
- The collection to compare to the current HashSetobject.
Example
The following example creates two HashSet collections with overlapping sets of data.
/*from w ww. j a va2s. c o m*/
using System;
using System.Collections.Generic;
public class MainClass{
public static void Main(String[] argv){
HashSet<int> lowNumbers = new HashSet<int>();
HashSet<int> highNumbers = new HashSet<int>();
for (int i = 0; i < 6; i++)
{
lowNumbers.Add(i);
}
for (int i = 3; i < 10; i++)
{
highNumbers.Add(i);
}
lowNumbers.SymmetricExceptWith(highNumbers);
}
}