VB.NET 2008/Visual Basic 2008
HashTable의 키 기준 정렬
본클라쓰
2012. 5. 29. 12:22
Dim ht As HashTable = GetHashTable()
For Each i As DictionaryEntry In ht
Console.WriteLine(i.type & ", " & i.result)
Next
위 처럼 작성된 코드는 입력된 순서와 상관없이 값이 출력됩니다.
이 때 키를 기준으로 정렬되어 값이 출력되게 하려면, SortedList를 이용합니다.
Dim s As SortedList(ht)
For Each i As DictionaryEntry In s
Console.WriteLine(i.Key & " " & i.Value)
Next