考慮下面的代碼:轉換字符串參數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