C# HashSet Comparer
Description
HashSet
gets the IEqualityComparer
Syntax
HashSet.Comparer
has the following syntax.
public IEqualityComparer<T> Comparer { get; }
Example
using System;// w ww.ja va2s. co m
using System.Collections.Generic;
public class MainClass{
public static void Main(String[] argv){
HashSet<int> evenNumbers = new HashSet<int>();
for (int i = 0; i < 5; i++)
{
evenNumbers.Add(i * 2);
}
Console.WriteLine(evenNumbers.Comparer);
}
}
The code above generates the following result.