Tag Archives: generics

Constraining Generic types to parameterized constructors

Pretty cool trick I found today on StackOverflow. I’ve often struggled with the fact that when you’re writing a generic method, while you can constrain the type of the method, you can only specify the constraint of having a constructor, and even then, only a default constructor (eg: new()); not one with parameters.