Generics in C#
Generics provide a way to write reusable code (methods, classes, interfaces) that can work with different types using a placeholder called a type parameter.
The type parameter is specified when the generic code is used, and can be any type (or constrained using where).
static T GetMin<T>(T first, T second) where T : IComparable<T> {
return first.CompareTo(second) < 0 ? first : second;
}
GetMin(1, 2);
GetMin("a", "b");