Color theme
0 day streak0 XPP1
C#Learn mode
MISSION 1 OF 1

Choose short reads with LINQ

0 XP earned
C# track: IntermediateMission: IntermediateLINQ filteringLambda expressionsBoundary conditions
Before you start this intermediate track

Typed collections and functions. Later missions use lambdas, LINQ, and nullable values.

Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.

x
0 / 2 challenges
LEARN THE CONCEPT

Understand it, then try it.

LINQ adds operations for working with sequences. Where keeps only values that satisfy a test, expressed here as a lambda. The parameter p represents one page count at a time. Enumerating the result with Join prints the qualifying counts in their original order, and the original array remains intact.

Program.cs
using System;using System.Linq;int[] pages = { 90, 150, 125, 310 };var shortReads = pages.Where(p => p < 150);Console.WriteLine(string.Join(", ", shortReads));

Use C# 10+ in a .NET 6+ console project. Each example is a complete Program.cs using top-level statements; the shown using directives are sufficient. Run missions separately.

Track the values line by line. Predict the result before running this example in your own editor.