本文整理匯總了VB.NET中System.Collections.Specialized.StringEnumerator類的典型用法代碼示例。如果您正苦於以下問題:VB.NET StringEnumerator類的具體用法?VB.NET StringEnumerator怎麽用?VB.NET StringEnumerator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了StringEnumerator類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: SamplesStringEnumerator
' 導入命名空間
Imports System.Collections.Specialized
Public Class SamplesStringEnumerator
Public Shared Sub Main()
' Creates and initializes a StringCollection.
Dim myCol As New StringCollection()
Dim myArr() As [String] = {"red", "orange", "yellow", "green", "blue", "indigo", "violet"}
myCol.AddRange(myArr)
' Enumerates the elements in the StringCollection.
Dim myEnumerator As StringEnumerator = myCol.GetEnumerator()
While myEnumerator.MoveNext()
Console.WriteLine("{0}", myEnumerator.Current)
End While
Console.WriteLine()
' Resets the enumerator and displays the first element again.
myEnumerator.Reset()
If myEnumerator.MoveNext() Then
Console.WriteLine("The first element is {0}.", myEnumerator.Current)
End If
End Sub
End Class
輸出:
red orange yellow green blue indigo violet The first element is red.