Sometimes when we are working with a query expression, we require a variable that can store the result of the sub-expression in order to reuse it in the upcoming clause. This type of facility is provided by the Let keyword. The Let keyword allows you to create a range variable and initialized with the result of the query expression and then you are allowed to use that variable with the upcoming clause in the same query. When you initialize a range variable with one value after that you are not allowed to store another value in the range variable.
Explanation: In the above example, the result is the query variable which stores the result of the given query expression. In the query expression, we created a range variable using let keyword, i.e, a1. In a1, we store the result of the s + 100 expressions. After that we use this variable in where clause to compare each element is greater than 150 or not and last we print those elements which are greater than 150.
Employee Name: rohit Employee Name: supriya
- What is Query in LINQ?
- LINQ | Set Operator | Except
- LINQ | Filtering Operator | where
- Aggregation Function in LINQ
- LINQ | Method Syntax
- LINQ | Partition Operator | Take
- LINQ | Quantifier Operator | Contains
- LINQ | Quantifier Operator | Any
- LINQ | Quantifier Operator | All
- LINQ | Element Operator | Last
- LINQ | Element Operator | First
- LINQ | Set Operator | Union
- LINQ | How to find the sum of the given Sequence?
- LINQ | Set Operator | Distinct
- LINQ | Query Syntax
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.