有人想猜猜执行结束时 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。这是我正在调试的函数的复制和粘贴,这在该上下文中有意义,但在这里意义不大。
最佳答案
评论太长,但这是我得到的。
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:\>
关于c# - linq min 问题/bug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2441530/