How to define this 'var' type formally?

This code:

var items = query.ToList();

returns List<'a> where 'a is new { string a1, string a2 }

If I were to remove the var keyword, what would be a valid type definition to use here that keeps the names a1 and a2?

Jon Skeet
people
quotationmark

Nothing, because it's a list of an anonymous type. The very term "anonymous type" was chosen because the type doesn't have a name.

If you want to be able to use explicit typing, don't use an anonymous type. Either create your own type, or (in C# 7) use a C# tuple type. (The regular System.Tuple type wouldn't let you preserve the names you want.)

people

See more on this question at Stackoverflow