C# PROGRAMMING
What is Generics in C#
Generics allows you to define placeholders for fields, methods, parameters, etc. It replaces the placeholder with some specific type at compile time.
Simple example of generic class
Below examples shows how to apply generics across class definition, variables, constructor, member functions & property.
As you can see below TestGenericClass is declared with “<T>” where <> defines its a generic class. The type of T will be defined later.
We can use any character instead of T.
How to use above class?
Here we will learn how to use the above generic class i.e. define type T inside the generic class.
Below an example of how we can use one generic class for different T types.