devxlogo

Use the Let Keyword to Create Variables in a LINQ Query

Use the Let Keyword to Create Variables in a LINQ Query

There are cases in which you will find the need to have variables inside a LINQ query to hold an evaluation result. The Let keyword helps in this case. See below for an example:

var oldTeens = from kidAge in kidsAges               let age = kidAge  14               where age               select kidAge;var result = oldTeens.ToList();
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist