Ejercicios de C#

Paginate with Skip and Take

Skip and Take compose a predictable page window after ordering.

How it works

Select one page from an ordered sequence.

For one-based page numbers, skip (page - 1) multiplied by the page size.

Runnable C# example

C#
Run code →
Program.cs
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        int page = 2, size = 3;
        var items = Enumerable.Range(1, 10).Skip((page - 1) * size).Take(size);
        Console.WriteLine(string.Join(", ", items));
    }
}
Expected output
4, 5, 6

Practice with the debugger

Set a breakpoint on an important assignment or condition, click Debug, and inspect the local values before stepping to the next line.