What is an equivalent to the “let” keyword in chained LINQ extension method calls?

Technology CommunityCategory: LINQWhat is an equivalent to the “let” keyword in chained LINQ extension method calls?
VietMX Staff asked 3 years ago

Essentially let creates an anonymous tuple. It’s equivalent to:

var result = names.Select(animal => new { animal = animal, nameLength = animal.Length })
    .Where(x => x.nameLength > 3)
    .OrderBy(y => y.nameLength)
    .Select(z => z.animal);