Imports System
Imports System.Collections
Imports System.Collections.Specialized
Public Class SamplesNameValueCollection
Public Shared Sub Main()
Dim myCol As New NameValueCollection()
myCol.Add("A", "aa")
myCol.Add("B", "bb")
myCol.Add("C", "cc")
myCol.Add("D", "dd")
myCol.Clear()
PrintKeysAndValues(myCol)
End Sub 'Main
Public Shared Sub PrintKeysAndValues(myCol As NameValueCollection)
Dim s As String
For Each s In myCol.AllKeys
Console.WriteLine(" {0,-10} {1}", s, myCol(s))
Next s
End Sub
Public Shared Sub PrintKeysAndValues2(myCol As NameValueCollection)
Dim i As Integer
For i = 0 To myCol.Count - 1
Console.WriteLine(" [{0}] {1,-10} {2}", i, myCol.GetKey(i), myCol.Get(i))
Next i
End Sub
End Class