我想找到这个数组的最小值和最大值.在某些时候它被设置为(512,512)UShorts. For循环对于这么多点非常耗时并且正在寻找更清洁的东西. SelectMany发生在我身上,但我不知道如何实现它. Dim u
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 millisecondsfor循环可能比您预期的耗时少得多.尝试计时它以查看使用嵌套循环查找最小和最大100,000次所需的时间.