我使用@:</div>
正确显示一些引导列。这是我的代码,我正使用它:VisualStudio自动格式不能正确格式化我的剃须刀代码
var i = 0;
<div class="container-fluid">
<div class="row show-grid">
@foreach (var one in Model)
{
if (i % 3 == 0)
{
@:<div class="row show-grid">
}
<div class="one-element col-md-4">
@one.Title
</div>
if ((i + 1) % 3 == 0)
{
@:</div>
}
i++;
}
</div>
</div>
它格式化的(这只要正常工作,因为我不使用VisualStudio
自动格式功能):
@:</div>
到这个:
@:
</div>
然后应用程序不再工作了。
这怎么解决?
附注:我认为用3进行组合并使用普通Razor构造进行渲染会更好,而不是使用不匹配的标签进行黑客攻击......但的确是一种选择。 –
@AlexeiLevenkov听起来不错。您能否提供一个示例或示例链接? –
'items.Select((value,index)=> new {value,index})。GroupBy(x => x.index/3)'或许多其他变体开始http://stackoverflow.com/questions/29606945/ how-to-build-batches-bucket-with-linq ...搜索 - https://www.bing.com/search?q=c%23+enumerable+buckets –