本文整理汇总了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
开发者ID:VB.NET开发者,项目名称:System.Collections,代码行数:49,代码来源:SortedList.CopyTo 输出:
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
注:本文中的System.Collections.SortedList.CopyTo方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论