Type Constraints

Generic code must work for every type of data. You can specify type constraints for a generic method or class which only allows type specified in the list of constraints. public class GenericClass<T> where T: constraint { //some code } Read more