I am creating a list in my controller and accessing it in view. I want to access the list data through for only loop not foreach loop this is my controller & view code
List < ViewModel > list = new List < ViewModel > ();
ViewModel model = new ViewModel();
string[] str1 = My name is Md Mohtesham;
model.a = str1[0];
model.b = str1[1];
model.c = str1[2];
model.d = str1[3];
model.e = str1[4];
list.add(model)
return View(list)
@model List<FD_Application.Models.ViewModel>
<table class="table table-bordered table-striped">
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
<th>d</th>
<th>e</th>
</tr>
@for(int i = 0; i < 5; i++)
{ <tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
}
</table>