本文整理汇总了VB.NET中System.Collections.Generic.List<T>.RemoveRange方法的典型用法代码示例。如果您正苦于以下问题:VB.NET List<T>.RemoveRange方法的具体用法?VB.NET List<T>.RemoveRange怎么用?VB.NET List<T>.RemoveRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.List<T>
的用法示例。
在下文中一共展示了List<T>.RemoveRange方法的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
输出:
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