本文整理汇总了VB.NET中System.Collections.Generic.List<T>.ToArray方法的典型用法代码示例。如果您正苦于以下问题:VB.NET List<T>.ToArray方法的具体用法?VB.NET List<T>.ToArray怎么用?VB.NET List<T>.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.List<T> 的用法示例。
在下文中一共展示了List<T>.ToArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: Example
' 导入命名空间
Imports System.Collections.Generic
Public Class Example
Public Shared Sub Main()
Dim input() As String = { "Brachiosaurus", _
"Amargasaurus", _
"Mamenchisaurus" }
Dim dinosaurs As New List(Of String)(input)
Console.WriteLine(vbLf & "Capacity: {0}", dinosaurs.Capacity)
Console.WriteLine()
For Each dinosaur As String In dinosaurs
Console.WriteLine(dinosaur)
Next
Console.WriteLine(vbLf & "AddRange(dinosaurs)")
dinosaurs.AddRange(dinosaurs)
Console.WriteLine()
For Each dinosaur As String In dinosaurs
Console.WriteLine(dinosaur)
Next
Console.WriteLine(vbLf & "RemoveRange(2, 2)")
dinosaurs.RemoveRange(2, 2)
Console.WriteLine()
For Each dinosaur As String In dinosaurs
Console.WriteLine(dinosaur)
Next
input = New String() { "Tyrannosaurus", _
"Deinonychus", _
"Velociraptor" }
Console.WriteLine(vbLf & "InsertRange(3, input)")
dinosaurs.InsertRange(3, input)
Console.WriteLine()
For Each dinosaur As String In dinosaurs
Console.WriteLine(dinosaur)
Next
Console.WriteLine(vbLf & "output = dinosaurs.GetRange(2, 3).ToArray")
Dim output() As String = dinosaurs.GetRange(2, 3).ToArray()
Console.WriteLine()
For Each dinosaur As String In output
Console.WriteLine(dinosaur)
Next
End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System.Collections.Generic,代码行数:58,代码来源:List.ToArray 输出:
Capacity: 3
Brachiosaurus
Amargasaurus
Mamenchisaurus
AddRange(dinosaurs)
Brachiosaurus
Amargasaurus
Mamenchisaurus
Brachiosaurus
Amargasaurus
Mamenchisaurus
RemoveRange(2, 2)
Brachiosaurus
Amargasaurus
Amargasaurus
Mamenchisaurus
InsertRange(3, input)
Brachiosaurus
Amargasaurus
Amargasaurus
Tyrannosaurus
Deinonychus
Velociraptor
Mamenchisaurus
output = dinosaurs.GetRange(2, 3).ToArray
Amargasaurus
Tyrannosaurus
Deinonychus
注:本文中的System.Collections.Generic.List<T>.ToArray方法示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论