C# generics

Updated: 28 January 2023

Generics are classes, structures, interfaces, and methods that have placeholders (type parameters) for one or more of the types that they store or use.

Generics introduces the concept of type parameters to .NET, which make it possible to design classes and methods that defer the specification of one or more types until the class or method is declared and instantiated by client code.

https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/generics

// Declare the generic class.
public class GenericList<T>
{
    public void Add(T input) { }
}

Leave a comment