本文整理汇总了VB.NET中System.Collections.ArrayList.GetEnumerator方法的典型用法代码示例。如果您正苦于以下问题:VB.NET ArrayList.GetEnumerator方法的具体用法?VB.NET ArrayList.GetEnumerator怎么用?VB.NET ArrayList.GetEnumerator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ArrayList
的用法示例。
在下文中一共展示了ArrayList.GetEnumerator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Program
' 导入命名空间
Imports System.Collections
Class Program
Private Shared Sub Main(ByVal args As String())
Dim colors As New ArrayList()
colors.Add("red")
colors.Add("blue")
colors.Add("green")
colors.Add("yellow")
colors.Add("beige")
colors.Add("brown")
colors.Add("magenta")
colors.Add("purple")
Dim e As IEnumerator = colors.GetEnumerator()
While e.MoveNext()
Dim obj As [Object] = e.Current
Console.WriteLine(obj)
End While
Console.WriteLine()
Dim e2 As IEnumerator = colors.GetEnumerator(2, 4)
While e2.MoveNext()
Dim obj As [Object] = e2.Current
Console.WriteLine(obj)
End While
End Sub
End Class
' This code example produces
' the following ouput:
' red
' blue
' green
' yellow
' beige
' brown
' magenta
' purple
'
' green
' yellow
' beige
' brown
'
示例2: MainClass
' 导入命名空间
Imports System
Imports System.Collections
Public Class MainClass
Public Shared Sub Main()
Dim arrayList As arrayList = New arrayList(1)
arrayList.Add("a")
try
Console.WriteLine(arrayList(0))
Catch outOfRange As ArgumentOutOfRangeException
Console.WriteLine(outOfRange.ToString())
End Try
Console.WriteLine(arrayList.Count)
Console.WriteLine(arrayList.Contains("a"))
Console.WriteLine(arrayList.IndexOf("a"))
arrayList.Remove("a")
arrayList.TrimToSize()
Console.WriteLine(arrayList.Capacity)
arrayList.Add("a")
Dim enumerator As IEnumerator = arrayList.GetEnumerator()
While enumerator.MoveNext()
Console.WriteLine(enumerator.Current )
End While
End Sub
End Class