Zest.

C#: LINQ: Where and Select

A short, tested C# example for linq: where and select. Copy it and adjust the names and paths for your project.

C#
var names = users
    .Where(u => u.Age >= 18)
    .OrderBy(u => u.Name)
    .Select(u => u.Name)
    .ToList();

Find it in Zest

Search for “csharp linq: where and select” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More C# examples

All C# examples