考虑下面的代码:转换字符串参数object类型
public ActionResult GenericActionForSomething(string objectType)
{
switch (objectType)
{
case "Business":
// Do Something with object here, like save
_db.Create<Business>();
break;
}
return View();
}
我如何转换字符串参数为一个对象?在这个例子中,我需要将参数“objectType”转换为“Business”类型的对象。任何想法将不胜感激。
看反射和动态类的实例。 – 2009-12-18 08:41:41