A
adrin
I want to make a generic type:
class Prunus<T, S> : BaseClass
where T : TBaseClass
where S : SBaseClass
{
public void DoSomething()
{
// the problem is here
T t = new T(arg1, arg2, ...);
}
}
In the code above, T(arg1, arg2, ...) is a constructor declared in
TBaseClass.
Unfortunately the args (arg1, arg2, ...) must be supplied to the constructor
(they are readonly fields in TBaseClass with only a getter supplied and so I
can't modify them) and using the new() constraint for T does not solve the
problem.
TBaseClass is a class in the BCL (think TreeViewEventArgs & co)... so I
can't change it
Any ideea on how to solve this problem?
class Prunus<T, S> : BaseClass
where T : TBaseClass
where S : SBaseClass
{
public void DoSomething()
{
// the problem is here
T t = new T(arg1, arg2, ...);
}
}
In the code above, T(arg1, arg2, ...) is a constructor declared in
TBaseClass.
Unfortunately the args (arg1, arg2, ...) must be supplied to the constructor
(they are readonly fields in TBaseClass with only a getter supplied and so I
can't modify them) and using the new() constraint for T does not solve the
problem.
TBaseClass is a class in the BCL (think TreeViewEventArgs & co)... so I
can't change it

Any ideea on how to solve this problem?