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();

devx-admin

Share the Post: