c# - Anonymous type with counter for each result -


is possible have counter going when creating linq query returning anonymous object?

e.g.

var results = foo in bar select new { foo.id, foo.name, counter = ???? }     

i tried defining method returns increasing number, end result same objects.

to clarify: want result

id, name, 1
id, name, 2
id, name, 3

etcetera

var counter = 0; var results =     foo in bar     select new { foo.id, foo.name, counter = ++counter };  

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -