Add a new constraint:
class Request<T> where T : new() { private T sw; public void Request() { sw = new T(); } }
This tells the compiler that T
will always have an accessible constructor without parameters (no, you cannot specify any other constructor).
jason source share