Getting index value on razor foreach
问题 I'm iterating a List<T> in a razor foreach loop in my view which renders a partial. In the partial I'm rendering a single record for which I want to have 4 in a row in my view. I have a css class for the two end columns so need to determine in the partial whether the call is the 1st or the 4th record. What is the best way of identifying this in my partial to output the correct code? This is my main page which contains the loop: @foreach (var myItem in Model.Members){ //if i = 1 <div class=