I have a generic method that takes in a type T, which i need to be able to call a constructor on that requires a single XmlNode. Currently, I am trying to do that by having an abstract base class that has the constructors I want (plus a parameterless one so i don't have to edit the "subclasses" other than to add the actual subclassing) and constraining by that. If i try to instantiate one of these classes, it complains that it:

Cannot create an instance of the variable type 'T' because it does not have the new() constraint

and if i add the new() constraint, i get:

'T': cannot provide arguments when creating an instance of a variable type

There is no way to specify that a generic type parameter T should have a constructor with a specified parameters. The fact that a base class has a constructor with some arguments doesn't help, because the overriden class doesn't have to have the same constructor (e.g. it can call the base constructor with some value as an argument).

The new() constraint can be used to require a parameter-less constructor only. I would probably suggest adding an interface constraint (e.g. IConstructFromXml) that would have a method to initialize the object - then you can call the method after you create the object using a parameterless constructor.

Alternatively, you could take a type parameter representing a factory for creating values of the specified type. Then you would create an instance of the factory and use it to create the value of the type you need. Something like: