I have some class, for example A, and others who extended A (A1,A2). The A is a container – it has only fields, any methods and properties.
Another class is B<T> where T : A, and extends of B (B1, B2)
Is it possible do that in c#?
public List<T<T1>> DoSomething(object parameter)
where T : B<T1>, new() where T1 : A, new()
In that method i must dynamic create T (B1 or B2 or B3) object and fill that generic object dynamic created T1 objects (A1, A2, A3). Yup i probably can use Activator, but use new T() will be better and use less casts
You don’t need
T<T1>To clean it up a little:
And assuming
AandBhave default constructors, you don’t need thenew()constraints.