本文整理匯總了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