'ASP.NET Core displays the last item of information

Sorry, I'm a newbie, and I'd like to ask if there's a way to show only the last piece of information.

   @{
    foreach (var item in Model)
    {
        <li>@item.Ax</li>       
    }
}

enter image description here



Solution 1:[1]

You can refer toEnumerable.Last Method

Try:

@{var last = Model.Last();}
@Html.DisplayFor(modelItem => last.Ax)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Qing Guo