Mega Code Archive

 
Categories / VB.Net / Data Structure
 

ListDictionary CopyTo Method copies the ListDictionary entries to a one-dimensional Array

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)       Dim myArr(myCol.Count) As DictionaryEntry       myCol.CopyTo(myArr, 0)       Dim i As Integer       For i = 0 To myArr.Length - 1          Console.WriteLine("   {0,-25} {1}", myArr(i).Key, myArr(i).Value)       Next i    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