C# 给List编个序号

给List编个号

 int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
 int i = 0;
 var q = (from n in numbers
          select (index:++i,number:n))
          .ToList();

foreach (var v in q)
{
     Console.WriteLine($"i = {v.index}, v = {v.number}");
}           

C# 给List编个序号_第1张图片

你可能感兴趣的:(c#,开发语言)