我有以下代码:
int[] numbers = new int[] { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; int i = 0; var query = from n in numbers select ++i; foreach (var n in query) Console.WriteLine("number = {0}, counter = {1}", n, i);
为什么即使我没有给出输出,输出也按递增顺序排序orderby
?
number = 1, counter = 1 number = 2, counter = 2 number = 3, counter = 3 number = 4, counter = 4 number = 5, counter = 5 number = 6, counter = 6 number = 7, counter = 7 number = 8, counter = 8 number = 9, counter = 9 number = 10, counter = 10
SLaks.. 6
select ++i
您正在选择i
,而不是数组中的值.
select ++i
您正在选择i
,而不是数组中的值.