Skip to main content
Home  › ... Razor

LINQ Tutorials

Tutorial HomeLINQ

Simple First() and Last()

This filters the authors with long first names.

Output

  1. First: Douglas
  2. Last: Ed
<ol>
  <li>
    First: @persons.First().FirstName
  </li>
  <li>
    Last: @persons.Last().FirstName
  </li>
</ol>

Source Code of this file

Below you'll see the source code of the file. Note that we're just showing the main part, and hiding some parts of the file which are not relevant for understanding the essentials. Click to expand the code

@inherits Custom.Hybrid.Razor14
@using ToSic.Razor.Blade;
@using System.Linq;
<!-- unimportant stuff, hidden -->


<div @Sys.PageParts.InfoWrapper()>
  @Html.Partial("../shared/DefaultInfoSection.cshtml")
  <div @Sys.PageParts.InfoIntro()>
    <h3>Simple First() and Last()</h3>
    <p>This filters the authors with long first names.</p>
  </div>
</div>

  <ol>
    <li>
      First: @persons.First().FirstName
    </li>
    <li>
      Last: @persons.Last().FirstName
    </li>
  </ol>



@* Footer *@
@Html.Partial("../Shared/Layout/FooterWithSource.cshtml", new { Sys = Sys })