我想找到这个数组的最小值和最大值。在某些时候,它被设置为(512, 512)
UShorts。对于这么多点,For 循环将非常耗时,并且正在寻找更清洁的东西。我想到了 SelectMany,但我不知道如何实现它。
Dim usResult As UShort(,)
编辑:我试过
Dim minValue As UShort = UShort.MaxValue
Dim maxValue As UShort = UShort.MinValue
Dim sw As New Stopwatch()
sw.Start()
For i As Integer = 0 To 511 Step 1
For j As Integer = 0 To 511 Step 1
minValue = Math.Min(usResult(i, j), minValue)
maxValue = Math.Max(usResult(i, j), maxValue)
Next
Next
sw.Stop()
Console.WriteLine(sw.ElapsedMilliseconds)
' This takes 2 to 3 milliseconds