In Visual Basic.net, what is the best way to find the smallest TimeSpan value in a list of TimeSpans as well as the Index of the TimeSpan in the List?
I know that I can sort the List, but how do I find the Index of the Item in the List?
Here is my current code:
I know that I can sort the List, but how do I find the Index of the Item in the List?
Here is my current code:
Code:
Public Function CalculateClosestScheduleStart(Schedule As Schedule) As TimeSpan
Dim TimeSpanList As New List(Of TimeSpan)
Dim Seconds As Double
Dim TimeSpan As TimeSpan
For x = 0 To Schedule.ScheduleItemList.Count - 1
Seconds = DateDiff(DateInterval.Second, Now, Schedule.ScheduleItemList(x).StartTime)
TimeSpan = TimeSpan.FromSeconds(Seconds)
TimeSpanList.Add(TimeSpan)
Next
For x = 0 To TimeSpanList.Count - 1
MsgBox(TimeSpanList(x).ToString)
Next
End Function