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.