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 | Query Syntax
- LINQ | Partition Operator | Take
- LINQ | How to find the sum of the given Sequence?
- LINQ | Filtering Operator | where
- LINQ | Element Operator | Last
- LINQ | Set Operator | Intersect
- LINQ | Set Operator | Union
- LINQ | Element Operator | First
- Aggregation Function in LINQ
- Cross Join in LINQ
- LINQ | Set Operator | Distinct
- LINQ | Quantifier Operator | Contains
- LINQ | Quantifier Operator | Any
- LINQ | Method Syntax
- LINQ | Quantifier Operator | All
- LINQ | Sorting Operator | OrderBy
- LINQ | Filtering Operator | OfType
- LINQ | Projection Operator | SelectMany
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.