Possible Duplicate:
C# foreach with index
I enjoy working the simplicity of foreach in C#, but I often need an index. Is there any way to combine these elegantly into one simple structure without doing the following:
for(var i = 0; i<items.Count; i++) {
var item = items[i];
Or
int i = 0;
foreach(var item in items) {
i++;
I'd imagine something neat like:
foreach(var item in items;int index) {