I have a foreach loop and need to execute some logic when the last item is chosen from the List, e.g.:
foreach
List
foreach (Item result in Mod
You could just use a for loop and there is no need to add an extra if inside the for body:
if
for
for (int i = 0; i < Model.Results.Count - 1; i++) { var item = Model.Results[i]; }
The -1 in the for condition takes care of skipping the last item.
-1