Home/Tutorials/C# (.NET)/LINQ Query Syntax

0 of 3 saved

C# (.NET)5 min read

LINQ Query Syntax

Read this chapter, write the program on this page, then pass a short check to open the next one.

Filter collections with LINQ.

LINQ Query Syntax

LINQ (Language Integrated Query) lets you filter and project collections. Where keeps matching elements.

  • Add using System.Linq;
  • Where(n => n % 2 == 0) keeps even numbers.
  • string.Join formats the result for printing.
using System;
using System.Linq;

int[] numbers = [1, 2, 3, 4, 5, 6];
var evens = numbers.Where(n => n % 2 == 0);
Console.WriteLine(string.Join(", ", evens));

After you read this chapter, use Write (when available) and Quiz on this page to lock it in โ€” same flow as C, Python, and the other Learn languages.