CKTIS / C#
System.Collections.Generic.IEqualityComparer: practical reference
System.Collections.Generic.IEqualityComparer: practical reference: IEqualityComparer<T> defines matching Equals and GetHashCode behavior for keys or elements.
Version: .NET API; verified on .NET 10.0.14
Syntax
System.Collections.Generic.IEqualityComparer /* select a documented member or constructor */IEqualityComparer defines matching Equals and GetHashCode behavior for keys or elements.
Use it to choose explicit equality semantics in dictionaries, sets, and LINQ operations.
Values considered equal must have the same hash code, and mutable hash state breaks later lookup.
The comparer must handle null as required by T and preserve symmetry and transitivity.
The complete program actually uses System.Collections.Generic.IEqualityComparer; its exact expected stdout is True.
Examples
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
IEqualityComparer<string> comparer = StringComparer.OrdinalIgnoreCase;
Console.WriteLine(comparer.Equals("Ada", "ADA"));
Result
True
The complete program actually uses `System.Collections.Generic.IEqualityComparer`; its exact expected stdout is `True`.