@{int i = 0;} @foreach(var myItem in Model.Members) { <span>@i</span> @{i++;} }
Tag: foreach
Change some value inside List
Let’s say you have a List of T. And there are Property1, Property2, Property3 in T. If you want to change the value of Property2 in T then you can use: var myList = List<T>; foreach (var item in myList) { item.Property2 = newValue; } or var myList = List<T>; myList.ForEach(x => x.Proprty2 = newValue); […]