本文整理匯總了VB.NET中System.Collections.SortedList.CopyTo方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET SortedList.CopyTo方法的具體用法?VB.NET SortedList.CopyTo怎麽用?VB.NET SortedList.CopyTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Collections.SortedList
的用法示例。
在下文中一共展示了SortedList.CopyTo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: SamplesSortedList
' 導入命名空間
Imports System.Collections
Public Class SamplesSortedList
Public Shared Sub Main()
' Creates and initializes the source SortedList.
Dim mySourceList As New SortedList()
mySourceList.Add(2, "cats")
mySourceList.Add(3, "in")
mySourceList.Add(1, "napping")
mySourceList.Add(4, "the")
mySourceList.Add(0, "three")
mySourceList.Add(5, "barn")
' Creates and initializes the one-dimensional target Array.
Dim tempArray() As String = {"The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"}
Dim myTargetArray(14) As DictionaryEntry
Dim i As Integer = 0
Dim s As String
For Each s In tempArray
myTargetArray(i).Key = i
myTargetArray(i).Value = s
i += 1
Next s
' Displays the values of the target Array.
Console.WriteLine("The target Array contains the following (before and after copying):")
PrintValues(myTargetArray, " "c)
' Copies the entire source SortedList to the target SortedList, starting at index 6.
mySourceList.CopyTo(myTargetArray, 6)
' Displays the values of the target Array.
PrintValues(myTargetArray, " "c)
End Sub
Public Shared Sub PrintValues(myArr() As DictionaryEntry, mySeparator As Char)
Dim i As Integer
For i = 0 To myArr.Length - 1
Console.Write("{0}{1}", mySeparator, myArr(i).Value)
Next i
Console.WriteLine()
End Sub
End Class
輸出:
The target Array contains the following (before and after copying): The quick brown fox jumps over the lazy dog The quick brown fox jumps over three napping cats in the barn