I have a class, Entity, that accepts a parameter in its constructor. For simplicity's sake, let's say it looks like this:
public class Entity
{
int number;
public Entity(int number)
{
this.number = number;
}
}
I'm trying to have a factory create these objects through a generic method:
public T Create<T>(int arg) where T : Entity
{
return new T(arg);
}
But I get the error:
'T': cannot provide arguments when creating an instance of a variable type
Is there any way to accomplish this without resorting to a (very ugly, imo) Initialize method or something to that degree
Thanks for the help.