I want to find the minimum and maximum values of this array. At some point it is set to (512, 512) UShorts. A For loop would be very time consuming for this many points and am looking for something cleaner. SelectMany occurred to me but I don’t know how to implement it.
Dim usResult As UShort(,)
edit:
I have tried
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
A for loop might be much less time-consuming than you expect. Try timing it to see how long it takes to find the min and max 100,000 times with nested loops.