Generic class is a class which can take a type as part of its definition.
Example:
public class ConsoleDisplay<T>
{
public void Display(T item)
{
Console.WriteLine(item);
}
}
The T is a placeholder for a type, which will be given as an input while creating an instance of the generic class.In the example below we create an instance of generic ConsoleDisplay<T> class, using string as a parameter.
public static void Main()
{
var consoleDisplay = new ConsoleDisplay<string>();
consoleDisplay.Display("Hello World!");
}
Result:Hello World!
In the same way we could create an object of type ConsoleDisplay<int> to process integer parameter.