I’ve have the following code example from Microsoft (http://msdn.microsoft.com/en-us/library/bb534869.aspx):
String[] fruits = {"apple", "banana", "mango", "orange", "passionfruit", "grape" };
var query = fruits.Select((fruit, index)
=> new {Substring = fruit.Substring(0, index)});
foreach (var obj in query)
Console.WriteLine("{0}", obj);
This works quite well, but what I m not understand is what type of query is?
I ve tried to get out the info from the debugger but i was not able to declare it and write it down explicitly. I ve tried several variants e.g.
IEnumerable<int,string> query = fruits.Select((fruit, index)
=> new {Substring = fruit.Substring(0, index)});
but this does build at all. How can I define the query type explicit without using var?
You cannot specify type because it is
anonymous. Read more here:http://msdn.microsoft.com/en-us/library/bb397696.aspx