Overview
Generic interfaces are type-safe counterparts to non-generic interfaces for ordering and equality comparisons and for functionality shared by generic collection types.
Availability: .NET 7
Framework-provided Generic Interfaces
For Equality and Ordering Comparisons
System.IComparable<T>
— methods for ordering comparisonsSystem.IEquatable<T>
— methods for equality comparisonsIComparer<T>
— define an ordering comparison for types that do not implementIComparable<T>
IEqualityComparer<T>
— define an equality comparison for types that do not implementIEquatable<T>
For Collection Functionality
ICollection<T>
— the basic interface for generic collection types; methods for adding, removing, copying, and enumerating elements; inherits fromIEnumerable<T>
andIEnumerable
.IList<T>
— extendsICollection<T>
with methods for indexed retrievalIDictionary<TKey, TValue>
— extendsICollection<T>
with methods for keyed retrievalIEnumerable<T>
— provides a generic enumerator structure; inheritsIEnumerator
, so any consumer of the non-generic interface can also consume this generic one