fork download
  1. using static System.Console;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Program {
  6. public static void Main() {
  7. var list = new List<int> { 1, 2, 3, 4, 5 };
  8. foreach (var pair in list.Select((x, i) => new {Index = i, Value = x})) WriteLine($"{pair.Index}: {pair.Value}");
  9. }
  10. }
  11.  
  12. //https://pt.stackoverflow.com/q/151272/101
Success #stdin #stdout 0.03s 17336KB
stdin
Standard input is empty
stdout
0: 1
1: 2
2: 3
3: 4
4: 5