Create IEqualityComparer object that can be used for equality testing of a HashSet in CSharp

Description

The following code shows how to create IEqualityComparer object that can be used for equality testing of a HashSet.

Example


//  w  w  w.  j a va 2 s.  com
using System;
using System.Collections.Generic;

public class MainClass
{
    public static void Main(String[] argv){
        IEqualityComparer<HashSet<int>> c = HashSet<int>.CreateSetComparer();
        
        Console.WriteLine(c);
    
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary