任何人都想知道在执行结束时currentIndex是什么?
int[] ints = new int[] { -1, 12, 26, 41, 52, -1, -1 };
int minInt = ints.Min();
这是110.有谁知道为什么?
将其包含在
下面的主要功能中using System;
using System.Linq;
class Sample {
public static void Main()
{
int[] ints = new int[] { -1, 12, 26, 41, 52, -1, -1 };
int minInt = ints.Min();
Console.WriteLine(minInt);
}
}
编辑:我从currentIndex将变量名称更改为minInt。它是我正在调试的函数的复制和粘贴,这在上下文中是有意义的,但在这里没有那么多。
答案 0 :(得分:3)
评论太长了,但这就是我得到的。
C:\>copy con t.cs
using System;
using System.Linq;
class Sample {
public static void Main()
{
int[] ints = new int[] { -1, 12, 26, 41, 52, -1, -1 };
int minInt = ints.Min();
Console.WriteLine(minInt);
}
}
^Z
1 file(s) copied.
C:\>csc t.cs
Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.4926
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.
C:\>t
-1
C:\>
答案 1 :(得分:1)
应为-1。另外,我认为“currentIndex”变量命名具有误导性。它实际上是数组中的最小值,而不是当前索引。例如,如果在该数组中添加-2,则上例中的变量currentIndex将为-2。