我有以下代码,其中已经声明了 depts 并且是类型的查询结果IEnumerable<dynamic>
我收到一条错误消息dept does not exist in the current context
。如果我注释掉 dept.Name 则没有错误。
@{
int I = 0;
for(I=0; I < dropdowndepts.Length; I++){
var depts = iStar.GetDepts() ;
<li class="header header_@I">
foreach(var dept in depts){
<li>@dept.Name</li>
}
</li>
}
}
好的新信息,如果我打破循环然后它编译。所以以下工作:
@{
int I = 0;
string[] dropdowndepts = new string[6]{"Store Logo","Clothing","Footwear","Outerwear","Gear","Deals"} ;
}
@for(I=0; I < dropdowndepts.Length; I++){
var depts = iStar.GetDepts() ;
@:<li class="header header_@I">
<ul>
@foreach(var dept in depts){
<li>@dept.Name</li>
}
</ul>
@:</li>
}