using System.Collections.Generic;
public static void Main()
var hashSet1 = new HashSet<int>();
var hashSet = new HashSet<int>() { 1, 2, 3, 4, 5, 6, 7, 8 };
foreach(int v in hashSet)
foreach(int v in hashSet)
var contains = hashSet.Contains(1);
Console.WriteLine(contains);
var count = hashSet.Count;
Console.WriteLine(count);
var another = new HashSet<int>(){1, 3, 5, 7, 9};
hashSet.IntersectWith(another);
foreach(int v in hashSet)
another = new HashSet<int>(){1, 3, 5};
hashSet.ExceptWith(another);
foreach(int v in hashSet)
another = new HashSet<int>(){2, 4, 6};
hashSet.UnionWith(another);
foreach(int v in hashSet)
var isSupersetOf = hashSet.IsSupersetOf(another);
Console.WriteLine(isSupersetOf);
var isSubsetOf = hashSet.IsSubsetOf(another);
Console.WriteLine(isSubsetOf);
var equals = hashSet.SetEquals(another);
Console.WriteLine(equals);
foreach(int v in hashSet)
foreach(int v in hashSet)