我有这个代码:
foreach (var row in App.cardSetWithWordCounts)
{
details.Children.Add(new SeparatorTemplate());
// do some tasks for every row
// in this part of the loop ...
}
Run Code Online (Sandbox Code Playgroud)
我想不添加一个SeparatorTemplate但是我想在第一次运行时执行其他任务foreach.有没有人有关于我如何做到这一点的建议?
我想在第一次执行代码中的其余代码foreach而不是添加模板的行.
Pat*_*man 11
如果要跳过第一行,可以使用Skip:
foreach (var row in App.cardSetWithWordCounts.Skip(1))
Run Code Online (Sandbox Code Playgroud)
如果您想知道确切的行号,请使用Select重载:
foreach (var x in App.cardSetWithWordCounts.Select((r, i) => new { Row = r, Index = i })
{
// use x.Row and x.Index
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
129 次 |
| 最近记录: |