0Pricing
C# Academy · Lesson

LINQ preview: Where, Select, OrderBy, Take/Skip; deferred execution

Build small LINQ pipelines over IEnumerable : filter with Where, transform with Select, order with OrderBy, and learn deferred execution vs materialization.

LINQ overview

Goal: Use tiny LINQ pipelines to filter, transform, and order data.

  • Where (filter)
  • Select (map)
  • OrderBy, Take/Skip
  • Deferred execution & materialization

Where + Select

Chain Where (filter) then Select (transform). Read left-to-right.

using System;
using System.Linq;

public class Program
{
  public static void Main(string[] args)
  {
    int[] data = new int[] { 1, 2, 3, 4, 5, 6 };

    // Filter even numbers, then square them
    var query = data.Where(x => x % 2 == 0)
                    .Select(x => x * x);

    foreach (int n in query)
    {
      Console.WriteLine(n); // 4, 16, 36
    }
  }
}

All lessons in this course

  1. Arrays, slicing, List , Dictionary
  2. foreach patterns; collection initializers
  3. LINQ preview: Where, Select, OrderBy, Take/Skip; deferred execution
← Back to C# Academy