Display the contents of the collection using the Keys, Values, Count, and Item properties : ListDictionary « Data Structure « VB.Net






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 

   
  








Related examples in the same category

1.Display the contents of the collection using For Each. This is the preferred method
2.Display the contents of the collection using the enumerator
3.Searches for a key