av:
Einar Høst
You know when you're iterating over some IEnumerable , and you need to associate the items in the IEnumerable with a sequence number? In Python, you could do this: In C#, however, you're forced to do something like this: var items = new [] { "zero", "one", "two" }; int no = 0; foreach (var it in items) { Console.WriteLine("{0} => {1}", no, it); ++no; } Yuck. I feel dirty each time. It's two measly lines of code, but it sure feels like I'm nailing something onto the loop that doesn't belon...
07.05.2011