I have a generic type who's gotten a function that creates an instance of the parameter type. When creating the parameter type, is there a way to use a constructor that takes arguments?
class MyGenericClass<T>
{
public T Create()
{
return new T("created by MyGenericClass");
}
}
Are there any constraints I can place on the type that qualifies it to be constructed with a parameter?
EDIT: My actual need is to use the parameter type as follows:
class MyGenericClass<T>
{
public T SomeFunction()
{
using (var t = new T("created by MyGenericClass"))
{
// actions with t
}
}
}