Am i trying to achieve the impossible or is it simply unnecessary? The code in GetList is the same for all specializations of the class A, apart from the bit to create a new instance of the specialization. There is no default constructor, always the same list of parameters.
At the moment I am using instead public static List<A> GetList(int i, Func<A> createMeAnInstance)
Which feels unclean.
abstract class A
{
protected A (int i)
{
}
public static List<T> GetList<T>(int i) where T : A
{
var list = new List<T>();
for(int x = 1; x< 100; x++)
{
var o = new T(i);
list.Add(o);
}
}
}
public class B : A
{
public B (int i) : base(i) {}
}
...
var list = A.GetList<B>(1);