I have this code:
foreach (var row in App.cardSetWithWordCounts)
{
details.Children.Add(new SeparatorTemplate());
// do some tasks for every row
// in this part of the loop ...
}
I would like to not do the adding of a SeparatorTemplate
BUT I would like to do the other tasks on the first run of the foreach
. Does anyone have a suggestion on how I can do this?
I want to execute the rest of the code in the foreach
but not the line adding the template on the first time around.
If you want to skip the first row, you can use Skip
:
foreach (var row in App.cardSetWithWordCounts.Skip(1))
If you want to know the exact row number, use the Select
overload:
foreach (var x in App.cardSetWithWordCounts.Select((r, i) => new { Row = r, Index = i })
{
// use x.Row and x.Index
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With