我在我的ASP.NET应用程序中具有以下代码,我想将converterName
变量转换为 类并将其传递给FillRequest<T>
方法。 这可能吗?将类字符串转换为类
var converterName = HttpContext.Current.Items["ConverterName"] as string;
FillRequest<Web2ImageEntity>(Request.Params);
我也可以做
var converterName = HttpContext.Current.Items["ConverterName"] as string;
if (converterName == "Web2ImageEntity")
FillRequest<Web2ImageEntity>(Request.Params);
,但我有大约20实体类和我想找到一种方法来编写代码尽可能短。
可能的重复http://stackoverflow.com/questions/1252371/initialize-a-class-by-string-variable-in-c – Reniuz
不,你的贴子不回答我的问题。 – Tomas