For each loop in Razor in ASP.NET MVC

How to perform for each loop in Razor view?

It is similar to the for loop except that it can be done only to those collection that has similar type of objects in it as it is in C#.
<ol> 
 @foreach (var variable in Request.ServerVariables) 
 { 
 <li>@variable</li>
 } 
</ol>

No comments:

Post a Comment

How to register multiple implementations of the same interface in Asp.Net Core?

 Problem: I have services that are derived from the same interface. public interface IService { } public class ServiceA : IService { ...