C#idiomatic C#
interfacesstandard/generics

Core library

Generic interfaces in .NET

Learn more about interfaces for generic types in .NET.

  • page standard/generics/interfaces
  • updated 07/25/2022

This article provides an overview of .NET's generic interfaces that provide common functionality across families of generic types.

Generic interfaces provide type-safe counterparts to nongeneric interfaces for ordering and equality comparisons, and for functionality that's shared by generic collection types. .NET 7 introduces generic interfaces for number-like types, for example, System.Numerics.INumber. These interfaces let you define generic methods that provide mathematical functionality, where the generic type parameter is constrained to be a type that implements a generic, numeric interface.

Equality and ordering comparisons

Collection functionality

Mathematical functionality

.NET 7 introduces generic interfaces in the System.Numerics namespace that describe number-like types and the functionality available to them. The 20 numeric types that the .NET base class library provides, for example, System.Int32 and System.Double, have been updated to implement these interfaces. The most prominent of these interfaces is System.Numerics.INumber, which roughly corresponds to a "real" number.

For more information about these interfaces, see Generic math.

See also