C# Order by in foreach

后端 未结 3 1622
死守一世寂寞
死守一世寂寞 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:36

    You can use the Linq OrderBy extension method

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

提交回复
热议问题