No, this is not a question about generics.
I have a Factory pattern with several classes with internal constructors (I don\'t want them being instantiated if not thr
To get around this, couldnt you just alter your usage as such:
public class GenericFactory where T : MyAbstractType
{
public static T GetInstance()
{
return Activator.CreateInstance(typeof(T), true);
}
}
Your factory method will still be generic, but the call to the activator will not use the generic overload. But you should still achieve the same results.