C# Order by in foreach

后端 未结 3 1589
死守一世寂寞
死守一世寂寞 2021-01-12 08:06

I\'m new to MVC C#.

Here is a ready and working code (the part of the working code).

@foreach (var item in Model)
{            
    
3条回答
  •  走了就别回头了
    2021-01-12 08:42

    Use OrderBy extension method on IEnumerable in System.Linq namespace

    @foreach (var item in Model.OrderBy(i => i.Order))
    {            
        
    @Html.Raw(@item.Description)
    }

提交回复
热议问题