Foreach loop, determine which is the last iteration of the loop
If you just need to do something with the last element (as opposed to something different with the last element then using LINQ will help here: Item last = Model.Results.Last(); // do something with last If you need to do something different with the last element then you’d need something like: Item last = Model.Results.Last(); … Read more