c# - linq min 问题/bug

标签 c# linq

有人想猜猜执行结束时 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/

相关文章:

c# - OR LIKE sql查询 bool 错误

c# - 基于窗口上设置的样式的样式未在设计器中显示(仅在运行时)

c# - 无法将 IEnumerable 类型转换为 IEnumerable

c# - 将Vb.Net Linq转换为C#但出现明显错误

c# - Select 和 SelectMany 的区别

c# - 动态添加 Or 条件

c# - 从显示的 dataGridView 中删除一行?

c# - Infragistics UltraGrid - 网格初始化后的事件

c# - 如何在 LinQ 组中连接字符串

c# - 我可以在 LINQ 中使用后置条件语句吗?