出处:http://www.cnblogs.com/lukun/archive/2011/07/28/2119180.html
@{
ViewBag.Title = "Home Page";
}
<h2>@ViewBag.Message</h2>
@{ var list = new List<string> { "admin", "jhob" };
}
@* 逻辑判断 *@
@if (list.Count > 0)
{
foreach (var person in list)
{
<li><a href="Index">@person</a></li>
}
}
@*文字输出变量输出*@
@{
@:(*^__^*) 嘻嘻
@:@list[0]
}
@*数据类型转换*@
@{ var i = "10";}
<p>
i=@i.AsInt();
</p>
@*循环*@
@for (int j = 0; j < list.Count; j++)
{
@:@j:
@:@list[j];
}