Display the contents of the collection using For Each. This is the preferred method : ListDictionary « Data Structure « VB.Net






Display the contents of the collection using For Each. This is the preferred method

 

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")

      PrintKeysAndValues(myCol)

   End Sub 'Main
   Public Shared Sub PrintKeysAndValues(myCol As IDictionary)
      Dim de As DictionaryEntry
      For Each de In  myCol
         Console.WriteLine("   {0,-25} {1}", de.Key, de.Value)
      Next de
   End Sub 
End Class 

   
  








Related examples in the same category

1.Display the contents of the collection using the enumerator
2.Display the contents of the collection using the Keys, Values, Count, and Item properties
3.Searches for a key