B
Brett Romero
I'd like to do this:
public class myclass<T>
{
myclass()
{}
public void CreateNew()
{
T myp = new T();
}
}
However, I get this compiler error:
Cannot create an instance of the variable type 'T' because it does not
have the new() constraint
I may type the class as Person. This means I want to create a new
Person object when CreateNew is called. Is there a way to do this?
Thanks,
Brett
public class myclass<T>
{
myclass()
{}
public void CreateNew()
{
T myp = new T();
}
}
However, I get this compiler error:
Cannot create an instance of the variable type 'T' because it does not
have the new() constraint
I may type the class as Person. This means I want to create a new
Person object when CreateNew is called. Is there a way to do this?
Thanks,
Brett