Mega Code Archive

 
Categories / VB.Net / Data Structure
 

Uses the Keys, Values, Count, and Item properties

Imports System Imports System.Collections Imports System.Collections.Specialized Public Class SamplesStringDictionary    Public Shared Sub Main()       Dim myCol As New StringDictionary()       myCol.Add("red", "R")       myCol.Add("green", "G")       myCol.Add("blue", "B")       PrintKeysAndValues3(myCol)    End Sub     Public Shared Sub PrintKeysAndValues3(myCol As StringDictionary)       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    End Sub  End Class