Syntax

C# LINQ Query Syntax

In C#, linq query: filters and transforms a collection — var big = nums.Where(n => n > 10).Select(n => n * 2).ToList();

Quick Answer

Syntax
var big = nums.Where(n => n > 10).Select(n => n * 2).ToList();
C#Syntax

LINQ Query

Code example
var big = nums.Where(n => n > 10).Select(n => n * 2).ToList();

Filters and transforms a collection.

Learn More

How to linq query in C#

  1. Open your C# file or editor.
  2. Copy the example, then replace its sample names and values for your code.

C# LINQ Query Syntax

Use var big = nums.Where(n => n > 10).Select(n => n * 2).ToList();.

Related Syntax References

Frequently asked questions

What is the C# syntax for linq query?

Use this pattern: var big = nums.Where(n => n > 10).Select(n => n * 2).ToList();

Can I copy this C# code example?

Yes. Use Copy code and adapt the example to your program.

Is this C# syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify