What is LINQ?

A query expression statement extracts specific information from a collection of data. The query syntax in C# is called Language Integrated Query, (LINQ). LINQs are used on collections of data, such as lists or arrays, which are container types for the IEnumerable<T> interface. Any container type of IEnumerable can use a LINQ.

To use a LINQ, include the following at the top of the code:

using system.Linq;// C# 10 comes with ImplicitUsings, meaning the most popular using namespaces such as this one are already built-in so there is no need to declare it

In the examples below, the various clauses that make up a query are covered. Clauses are a smaller syntax than a full expression; LINQs require multiple clauses to be a complete expression.

Get hands-on with 1400+ tech skills courses.