0Pricing
C# Academy · Lesson

Select, Where, OrderBy, Take/Skip

Filter with Where, transform with Select, sort with OrderBy/ThenBy, and page with Take/Skip. Simple, readable chains.

Select, Where, OrderBy, Take/Skip is a free C# Academy lesson on CoddyKit — lesson 2 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the C# Academy learning path, one of 3 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Operator roles

Roles:

  • Where filters
  • Select transforms
  • OrderBy/ThenBy sorts
  • Take/Skip page results

Keep chains short and readable.

Filtering with Where

Where keeps items that satisfy a condition (predicate).

using System;
using System.Linq;

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

    var evens = nums.Where(n => n % 2 == 0);

    foreach (int n in evens)
    {
      Console.WriteLine(n); // 2 4 6
    }
  }
}

Projection with Select

Select transforms each element into a new value (projection).

using System;
using System.Linq;

public class Program
{
  public static void Main(string[] args)
  {
    string[] words = new string[] { "cat", "lion", "tiger" };

    var lengths = words.Select(w => w.Length); // transform to lengths

    foreach (int len in lengths)
    {
      Console.WriteLine(len); // 3 4 5
    }
  }
}

Ordering results

Use OrderBy then ThenBy for multi-key sorting; add Descending when needed.

using System;
using System.Linq;

public sealed class City
{
  public string Name;
  public int Population;
  public City(string name, int pop) { Name = name; Population = pop; }
}

public class Program
{
  public static void Main(string[] args)
  {
    City[] cities = new City[]
    {
      new City("Rome", 2873000),
      new City("Oslo", 634000),
      new City("Riga", 605000),
      new City("Rio", 6748000)
    };

    var sorted = cities
      .OrderBy(c => c.Name)             // primary
      .ThenByDescending(c => c.Population); // secondary

    foreach (City c in sorted)
    {
      Console.WriteLine(c.Name + " - " + c.Population);
    }
  }
}

Paging with Take/Skip

Skip moves past items; Take returns a fixed count. Together they implement paging.

using System;
using System.Linq;

public class Program
{
  public static void ShowPage(int[] data, int page, int pageSize)
  {
    var pageItems = data
      .OrderBy(x => x)           // define a consistent order
      .Skip((page - 1) * pageSize)
      .Take(pageSize);

    Console.WriteLine("Page " + page + ":");
    foreach (int x in pageItems) Console.WriteLine(x);
  }

  public static void Main(string[] args)
  {
    int[] nums = new int[] { 9, 1, 5, 2, 7, 3, 8, 6, 4 };
    ShowPage(nums, 1, 3); // 1 2 3
    ShowPage(nums, 2, 3); // 4 5 6
  }
}

Chaining tips

Tips:

  • Filter early with Where.
  • Project late with Select (after filtering/sorting).
  • Use OrderBy before Take/Skip for predictable results.
  • Keep each step small and named clearly.

Filter operator name

Quick check: Which LINQ operator filters a sequence by a predicate?

Recap

Recap: Use Where to filter, Select to project, OrderBy/ThenBy to sort, and Take/Skip to page. Keep pipelines small and readable.

Frequently asked questions

Is the “Select, Where, OrderBy, Take/Skip” lesson free?

Yes — the full text of “Select, Where, OrderBy, Take/Skip” is free to read here on the web, and the C# Academy course includes 3 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the C# Academy course, upgrade to CoddyKit PRO.

What will I learn in “Select, Where, OrderBy, Take/Skip”?

Filter with Where, transform with Select, sort with OrderBy/ThenBy, and page with Take/Skip. Simple, readable chains. You practise C# Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start C# Academy?

No prior experience is required. C# Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 3, so you can start here or from the beginning and move at your own pace.

How long does the “Select, Where, OrderBy, Take/Skip” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this C# Academy lesson?

Yes. Every C# Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. IEnumerable pipelines; deferred execution
  2. Select, Where, OrderBy, Take/Skip
  3. Query vs method syntax
← Back to C# Academy