VB.Net Tutorial/Collections/SortedList

Материал из VB Эксперт
Перейти к: навигация, поиск

SortedList

Imports System.Collections
public class Test
   public Shared Sub Main
        
        Dim jobs As New SortedList
        jobs.Add("02", "Two")
        jobs.Add("10", "Ten")
        jobs.Add("01", "One")
        jobs.Add("06", "Six")
        For i As Integer = 0 To jobs.Count - 1
            Console.WriteLine(jobs.GetKey(i).ToString() & ": " & _
                jobs.GetByIndex(i).ToString())
        Next i
        jobs.Clear()
        jobs.Add(2, "Two")
        jobs.Add(10, "Ten")
        jobs.Add(1, "One")
        jobs.Add(6, "Six")
        For i As Integer = 0 To jobs.Count - 1
            Console.WriteLine(jobs.GetKey(i).ToString() & ": " & _
                jobs.GetByIndex(i).ToString())
        Next i
   End Sub
End class
01: One
02: Two
06: Six
10: Ten
1: One
2: Two
6: Six
10: Ten