SortedList.GetByIndex Method gets the value at the specified index of a SortedList object.
Imports System
Imports System.Collections
Imports Microsoft.VisualBasic
Public Class SamplesSortedList
Public Shared Sub Main()
Dim mySL As New SortedList()
mySL.Add(1.3, "1.3")
mySL.Add(1.4, "1.4")
mySL.Add(1.5, ".15")
Dim myIndex As Integer = 3
Console.WriteLine("The key at index {0} is {1}.", myIndex,mySL.GetKey(myIndex))
Console.WriteLine("The value at index {0} is {1}.", myIndex,mySL.GetByIndex(myIndex))
Dim myKeyList As IList = mySL.GetKeyList()
Dim myValueList As IList = mySL.GetValueList()
Dim i As Integer
For i = 0 To mySL.Count - 1
Console.WriteLine("{0}{1}", myKeyList(i), myValueList(i))
Next i
End Sub
End Class
Related examples in the same category