What is Where() in LINQ?

Easy0-2 Years

Where()

Where() filters records based on a condition.

Syntax

collection.Where(x => condition);

Example

var result = employees
    .Where(x => x.Salary > 50000);

Output

Returns only matching records.

Interview Tips

Where() returns IEnumerable.