SortedList.SetByIndex Method replaces the value at a specific index in 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(2, "two")
mySL.Add(3, "three")
mySL.Add(1, "one")
mySL.SetByIndex(3, "III")
mySL.SetByIndex(4, "IV")
PrintIndexAndKeysAndValues(mySL)
End Sub 'Main
Public Shared Sub PrintIndexAndKeysAndValues(myList As SortedList)
Dim i As Integer
For i = 0 To myList.Count - 1
Console.WriteLine("[{0}]:{1}{2}", i, myList.GetKey(i),myList.GetByIndex(i))
Next i
End Sub
End Class
Related examples in the same category