Mega Code Archive

 
Categories / VB.Net / Data Structure
 

Display the contents of the collection using the Keys, Values, Count, and Item properties

Imports System Imports System.Collections Imports System.Collections.Specialized Public Class SamplesListDictionary       Public Shared Sub Main()       Dim myCol As New ListDictionary()       myCol.Add("A", "a")       myCol.Add("B", "b")       myCol.Add("C", "c")       PrintKeysAndValues3(myCol)    End Sub 'Main    Public Shared Sub PrintKeysAndValues3(myCol As ListDictionary)       Dim myKeys(myCol.Count) As [String]       myCol.Keys.CopyTo(myKeys, 0)       Dim i As Integer       For i = 0 To myCol.Count - 1          Console.WriteLine("   {0,-5} {1,-25} {2}", i, myKeys(i), myCol(myKeys(i)))       Next i       Console.WriteLine()    End Sub  End Class