Choose short reads with LINQ
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.
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.
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.