- Declaring a generic class is actually very easy. All that we need to do is create the class with the generic type parameter <T>:
public class PerformAction<T> { }
The generic type parameter is basically a placeholder for a specific type that will need to be defined when the class of variable is instantiated. This means that the generic class PerformAction<T> can never just be used without specifying the type argument inside angle brackets when instantiating the class.
- Next, create a private variable of the generic type parameter T. This will hold the value we pass to the generic class:
public class PerformAction<T> { private T _value; }
- We now need to add a constructor to the generic class. The constructor will ...