C# LINQ — “All”

LINQ (Language-Integrated Query) is a set of integrated C# capabilities which allow queries against data.

Vincent Taylor
2 min readJan 5, 2022

Today’s Objective: Go over the LINQ All function used to search a data collection and check if all entries meet a certain condition.

The LINQ All Method:

Similar to, and also kind of the opposite of, the Any function, the All function searches the data collection and checks if all values meet a specific condition, returning a boolean if that is true.

The Any method is kind of like using “||” (OR), while the All method is like using “&&” (AND) to check collection values for a condition/s.

Microsoft Documentation

An Example:

By using LINQ All instead of a normal C# ForEach loop and an If statement, you cna reduce the complexity and line count of the operation.

The Syntax:

Note: “name” can be called whatever you want, just like “nameFound”. Since mine is a string[] of names, “name” is an appropriate variable name.

--

--

Vincent Taylor

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.