比如有这么一个方法,其中的T是个类,比如这个类名叫Person,但是我只能知道string p="Person";,怎样才能转换成Person类,然后调用这个方法
public static void ResponoseXml<T>(T response, string code, string msg)
{
response.GetType().GetProperty("ErrCode").SetValue(response, code, null);
response.GetType().GetProperty("ErrMsg").SetValue(response, msg, null);
}
http://www.cnblogs.com/muou/archive/2009/07/08/1518971.html
用反射Assembly,不过你需要用完整的带命名空间的类名,你自己在项目中要有Person类,然后带上命名空间名字就可以创建了
http://www.cnblogs.com/Joetao/articles/2112492.html
这个问题可以通过反射解决。
http://www.cnblogs.com/psunny/archive/2009/08/19/1548529.html