0

I have a class definition like this:

public class LuRequest<T>
    {
...
    }

I want to create a instance of it by assigning the type T dynamically like

Type t = OtherObject.GetType();
LuRequest< t>  inst = new LuRequest<t>();

However it does not allow me do so, everything in the brackets need to be in compile time. Is there any way I can do that?

Thank you

Honghao
  • 21
  • 3

1 Answers1

-1

Try to use Activator.CreateInstance() method. http://msdn.microsoft.com/en-gb/library/system.activator.createinstance.aspx

Nikita
  • 422
  • 5
  • 14
  • This is a borderline link-only answer. You should expand your answer to include as much information here, and use the link only for reference. – gunr2171 Dec 15 '14 at 18:43