Mega Code Archive

 
Categories / VB.Net / Data Structure
 

SortedList Class represents a collection of keyvalue pairs that are sorted by the keys

Imports System Imports System.Collections Imports Microsoft.VisualBasic Public Class SamplesSortedList     Public Shared Sub Main()         Dim mySL As New SortedList()         mySL.Add("A", "!")         mySL.Add("B", "World")         mySL.Add("C", "Hello")         Console.WriteLine("  Count:    {0}", mySL.Count)         Console.WriteLine("  Capacity: {0}", mySL.Capacity)         PrintKeysAndValues(mySL)     End Sub     Public Shared Sub PrintKeysAndValues(myList As SortedList)         Dim i As Integer         For i = 0 To myList.Count - 1             Console.WriteLine("{0}:" & "{1}", myList.GetKey(i), myList.GetByIndex(i))         Next i     End Sub End Class