Mega Code Archive

 
Categories / VB.Net / Data Structure
 

When you use foreach to enumerate dictionary elements, the elements are retrieved as KeyValuePair objects

Imports System Imports System.Collections.Generic Public Class Example     Public Shared Sub Main()          Dim openWith As New SortedDictionary(Of String, String)         openWith.Add("A", "a")         openWith.Add("B", "b")         openWith.Add("C", "c")         openWith.Add("D", "d")         For Each kvp As KeyValuePair(Of String, String) In openWith             Console.WriteLine("Key = {0}, Value = {1}", _                 kvp.Key, kvp.Value)         Next kvp     End Sub End Class