Sunday, September 24, 2006

.NET : Genric Collection

^ 对于Generic Dictionary的程序写法:

Dim OneGenericDictionary As New Dictionary(Of Integer, String)
OneGenericDictionary.Add(1, "One")
OneGenericDictionary.Add(2, "Two")
OneGenericDictionary.Add(3, "Three")

For Each OnePare As KeyValuePair(Of Integer, String) In OneGenericDictionary
Console.WriteLine("The pare is {0} : {1}", OnePare.Key.ToString, OnePare.Value.ToString)
Next

Dim OneEnumerator As Dictionary(Of Integer, String).Enumerator = OneGenericDictionary.GetEnumerator()
While OneEnumerator.MoveNext
Console.WriteLine(OneEnumerator.Current.Key & " : " & OneEnumerator.Current.Value)
End While