How do I specify the type of the range variable in a LINQ query?

c#, linq, winforms

Solution

Just declare it with the variable itself:

var query = from string text in collection
            where text.Length > 5
            select text.ToUpper();

This will translate to:

var query = collection.Cast<string>()
                      .Where(text => text.Length > 5)
                      .Select(text => text.ToUpper());

Problem

How do I specify the type of the range variable in a linq query?

Original source