在這裏用MVC打破我的頭。還挺好奇的動態類型在MVC視圖
,我寫我的模型爲:
public class AboutModel
{
public string AboutText { get; set; }
}
和我的控制器:
public ActionResult About()
{
var model = new AboutModel { AboutText = "We build better software."};
return View(model);
}
,改變了new
行:
AboutModel model = new AboutModel { AboutText = "We build better software."}
終於到:
dynamic model = new AboutModel { AboutText = "We build better software."}
似乎所有的作品非常清楚我的View
:
@model MvcApp.Models.AboutModel
<p>@if (Model != null)
{
@Model.AboutText
}</p>
任何差異在我3模式初始化?
在這個問題上,你可以瞭解三種類型: [鏈接](http://stackoverflow.com/questions/961581/whats-the-difference-between-dynamicc-4-and-var) –