Looping through models content in Razor

前端 未结 3 553
既然无缘
既然无缘 2021-02-05 16:39

I want to loop through each item in my model in my razor view but I want to group all items together. I then want to loop through each group. Imagine I have a table:

<         


        
3条回答
  •  你的背包
    2021-02-05 17:16

    @{
        Layout = null;
    }
    
    
    
        
        Index
    
    
        
    @{ String[] name = {"Prashant", "Rishabh", "Zaheer", "Pratima", "Rahul"}; int i = 1; while (i <= 5) { foreach(var x in name) {

    @i. @x

    i++; }; break; } }
    O/p- 1. Prashant 2. Rishabh 3. Zaheer 4. Pratima 5. Rahul

提交回复
热议问题