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
using Linq and the foreach:
foreach (Item result in Model.Results) { if (Model.Results.IndexOf(result) == Model.Results.Count - 1) { // this is the last item } }
https://code.i-harness.com/en/q/7213ce