LINQ Filtering

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/17

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:14 AM on 8/8/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

18 Terms

1
New cards

Where()

A LINQ filtering operator provided by Enumerable that returns only the elements of a sequence that satisfy a specified condition. Domain: C# → .NET → System.Linq → LINQ Filtering

2
New cards

var results = numbers.Where(n => n > 10);

Returns a sequence containing only numbers greater than 10.

3
New cards

var results = numbers.Where(n => n % 2 == 0);

Returns a sequence containing only even numbers.

4
New cards

var results = numbers.Where(n => n >= 10 && n <= 20);

Returns only elements whose values fall within the inclusive range from 10 through 20.

5
New cards

var results = numbers.Where(n => n < 0 || n > 100);

Returns elements satisfying either of the specified conditions.

6
New cards

var results = names.Where(name => name.StartsWith("A"));

Returns only strings that begin with the specified text.

7
New cards

var results = names.Where(name => name.Contains("son"));

Returns only strings containing the specified substring.

8
New cards

var results = names.Where(name => name.Length >= 5);

Returns only strings whose length is at least 5 characters.

9
New cards

var results = people.Where(person => person.Age >= 18);

Filters a sequence of objects according to the value of one of their properties.

10
New cards

var results = people.Where(p => p.Age >= 18 && p.IsActive);

Filters objects using multiple conditions that must all evaluate to true.

11
New cards

var results = items.Where(item => item != null);

Returns only elements that are not null.

12
New cards

var results = numbers.Where((number, index) => index % 2 == 0);

Uses the indexed overload of Where() to return elements located at even sequence indexes.

13
New cards

var results = numbers.Where((number, index) => number > index);

Uses both an element's value and its zero-based sequence index when deciding whether to include it.

14
New cards

var results = numbers.Where(n => n > 0).Where(n => n % 2 == 0);

Chains multiple Where() operations so an element must survive each successive filtering operation.

15
New cards

var results = values.OfType();

Returns only elements that are compatible with string and exposes the resulting sequence as IEnumerable.

16
New cards

var results = values.OfType();

Returns only elements that are compatible with int from a sequence containing values of different runtime types.

17
New cards

OfType()

A LINQ filtering operator that selects only elements that can be treated as the specified type T and excludes incompatible elements.

18
New cards

Where() vs OfType()

Where() filters elements according to a Boolean condition, whereas OfType() filters according to runtime type compatibility and returns the matching elements as that type.