Mega Code Archive

 
Categories / VB.Net / Data Structure
 

When using foreach to enumerate list 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 SortedList(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