gpt4 book ai didi

c# - linq 最小问题/错误

转载 作者:行者123 更新时间:2023-11-30 21:22:02 24 4
gpt4 key购买 nike

有人想猜猜执行结束时 currentIndex 是什么吗?

        int[] ints = new int[] { -1, 12, 26, 41, 52, -1, -1 };
int minInt = ints.Min();

是110,有谁知道为什么吗?

在下面封装了一个main函数

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 最小问题/错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2441530/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com