Using the C# compilers query comprehension features, you can write code like:
var names = new string[] { "Dog", "Cat", "Giraffe", "Monkey", "Tortoise" };
var result =
from animalName in names
let nameLength = animalName.Length
where nameLength > 3
orderby nameLength
select animalName;
In the query expression above, the let
keyword allows a value to be passed forward to the where and orderby operations without duplicate calls to animalName.Length
.
What is the equivalent set of LINQ extension method calls that achieves what the "let" keyword does here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…