Learn how to use LINQ in your applications with these code samples, covering the entire range of LINQ functionality and demonstrating LINQ to objects, and LINQ to XML.
Learn how to generate a single value from a sequence
Combine multiple sequences into a single source sequence.
Convert sequences of one type into another.
Learn how to build seqeunces from multiple inputs.
Use the index of items in a sequence during a query.
Compare sequences for equality.
Generate sequences by running a query.
Group items into sub-sequences.
Combine multiple sequences into a single sequence by matching values on properties.
Sort sequences.
Dividing an input sequence into two parts without rearranging them and then returning one of the parts.
Transform sequences into new types.
Test for all or any elements matching a condition.
Learn about deferred and immediate query execution.
Filter sequences using Where
.
Learn about set operations such as Distinct
, Except
, Intersect
,
and Union
.
To build and run the sample, type the following two commands in any of the subdirectories:
dotnet restore
dotnet run
dotnet restore
restores the dependencies for this sample.
dotnet run
builds the sample and runs the output assembly.
Note: Starting with .NET Core 2.0 SDK, you don't have to run dotnet restore
because it's run implicitly by all commands that require a restore to occur, such as dotnet new
, dotnet build
and dotnet run
. It's still a valid command in certain scenarios where doing an explicit restore makes sense, such as continuous integration builds in Azure DevOps Services or in build systems that need to explicitly control the time at which the restore occurs.