Generis x Reflection

I have to do something like this...

protected void Page_Load(object sender, EventArgs e){

string _TypeName = "Blah.MyClass";
Response.Write(x<_TypeName>());

}
public string x<type>()
{
return "";
}

i am using reflection to instance the my class and pass to test...but it doesn't works...

can you help me ?

[351 byte] By [AlexandreMartins] at [2007-12-22]
# 1
I don't think you're going to be able to make this work. x<T> gets generated before the code executes, so _TypeName won't have been initialized. You can work around this somewhat by using code generation. Basically, you would have to write a method that generates a type with a member that returns a specified kind of generic. Even then, though, you'll only have access to any non-generic base or interface that the generic implements, because you'll be late-bound to it. You would essentially lose the strong-typing benefits that generics provide.
PhilN at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 2
What you are trying to do in your example (using generics) is just not going to work. But, I'm sure I can find a working way to do what you really want, if you gave a better example of what that is. (ie, given your present example, the whole thing could be replaced by:
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("");
}

but that's not what you really want.

JamesCurran at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...