【发布时间】:2017-01-12 03:19:25
【问题描述】:
如何从这个例子中得到最小值和最大值
Public Class RowsFound
Property RowIndex As integer
Property Qty As Integer
Property LineValue As Double
End Class
Dim Test as new List(Of RowsFound)
根据最大 LineValue 和 Min LineValue 的 RowIndex 获取 RowIndex 的最佳方法是什么
我已将其作为测试,但想看看是否有更好的方法。
Dim MaxRow As Integer = 0
Dim MaxRowValue As Integer = 0
Dim MinRow As Integer = 999999
Dim MinRowValue As Integer = 999999
For Each MinMaxitem As RowsFound In ListOfRows
If MinMaxitem.LineValue < MinRowValue Then
MinRow = MinMaxitem.RowIndex
MinRowValue = MinMaxitem.LineValue
End If
If MinMaxitem.LineValue > MaxRowValue Then
MaxRow = MinMaxitem.RowIndex
MaxRowValue = MinMaxitem.LineValue
End If
Next
谢谢你:)
【问题讨论】:
-
你尝试过什么吗? “最好”是什么意思?最少的代码?执行速度最快?最容易维护?
-
是的,我会说最少和最快的将是完美的。 :)
标签: vb.net ienumerable