VB.Net by API/System.Collections/SortedList

Материал из VB Эксперт
Версия от 15:51, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

SortedList.Add

<source lang="vbnet"> Imports System Imports System.Collections Imports System.Collections.Specialized

Public Class MainClass

   Shared Sub Main(ByVal args As String())
       Dim sorted_list As SortedList
       " Use a normal, case-sensitive SortedList.
       sorted_list = New SortedList
       sorted_list.Add("A", "A")
       sorted_list.Add("a", "B")        
       
       For Each obj As Object In sorted_list
           Console.WriteLine(obj)
       Next obj
       
   End Sub

End Class


 </source>


SortedList.GetByIndex

<source lang="vbnet"> Imports System Imports System.Collections Imports System.Collections.Specialized

Public Class MainClass

   Shared Sub Main(ByVal args As String())
       Dim sortedList As New SortedList
       sortedList.Add("2", "T")
       sortedList.Add("0", "T")
       sortedList.Add("1", "O")
       sortedList.Add("6", "S")
       For i As Integer = 0 To sortedList.Count - 1
           Console.WriteLine(sortedList.GetKey(i).ToString() & ": " & _
               sortedList.GetByIndex(i).ToString())
       Next i
       sortedList.Clear()
   End Sub

End Class


 </source>


SortedList.GetKey

<source lang="vbnet"> Imports System Imports System.Collections Imports System.Collections.Specialized

Public Class MainClass

   Shared Sub Main(ByVal args As String())
       Dim sortedList As New SortedList
       sortedList.Add("2", "T")
       sortedList.Add("0", "T")
       sortedList.Add("1", "O")
       sortedList.Add("6", "S")
       For i As Integer = 0 To sortedList.Count - 1
           Console.WriteLine(sortedList.GetKey(i).ToString() & ": " & _
               sortedList.GetByIndex(i).ToString())
       Next i
       sortedList.Clear()
   End Sub

End Class


 </source>