StringDictionary.CopyTo Method copies dictionary values to a one-dimensional Array
Imports System
Imports System.Collections
Imports System.Collections.Specialized
Imports Microsoft.VisualBasic
Public Class SamplesStringDictionary
Public Shared Sub Main()
Dim myCol As New StringDictionary()
myCol.Add("red", "R")
myCol.Add("green", "G")
myCol.Add("blue", "B")
Dim myDE As DictionaryEntry
For Each myDE In myCol
Console.WriteLine("{0}{1}", myDE.Key, myDE.Value)
Next myDE
Dim myArr As DictionaryEntry() = {New DictionaryEntry(), New DictionaryEntry(), New DictionaryEntry()}
myCol.CopyTo(myArr, 0)
Dim i As Integer
For i = 0 To myArr.Length - 1
Console.WriteLine("{0}" + ControlChars.Tab + "{1}", myArr(i).Key, myArr(i).Value)
Next i
End Sub
End Class
Related examples in the same category