ValidatorCollection.GetEnumerator 方法

定义

返回 IEnumerator 集合的 ValidatorCollection 实例。Returns an IEnumerator instance for the ValidatorCollection collection.

public:
 virtual System::Collections::IEnumerator ^ GetEnumerator();
public System.Collections.IEnumerator GetEnumerator ();
abstract member GetEnumerator : unit -> System.Collections.IEnumerator
override this.GetEnumerator : unit -> System.Collections.IEnumerator
Public Function GetEnumerator () As IEnumerator

返回

集合的 IEnumeratorThe IEnumerator for the collection.

实现

示例

下面的代码示例演示如何使用GetEnumerator方法。The following code example demonstrates using the GetEnumerator method.

// Get 'Validators' of the page to myCollection.
ValidatorCollection myCollection = Page.Validators;

// Get the Enumerator.
IEnumerator myEnumerator = myCollection.GetEnumerator();
// Print the values in the ValidatorCollection.
string myStr = " ";
while ( myEnumerator.MoveNext() )
{
   myStr += myEnumerator.Current.ToString();
   myStr += " ";
}
messageLabel.Text = myStr;
' Get 'Validators' of the page to myCollection.
Dim myCollection As ValidatorCollection = Page.Validators
' Get the Enumerator.
Dim myEnumerator As IEnumerator = myCollection.GetEnumerator()
' Print the values in the ValidatorCollection.
Dim myStr As String = " "
While myEnumerator.MoveNext()
   myStr += myEnumerator.Current.ToString()
   myStr += " "
End While
messageLabel.Text = myStr

注解

使用此方法创建一个System.Collections.IEnumerator实例, 该实例可循环访问以获取集合中的ValidatorCollection每个项。Use this method to create an System.Collections.IEnumerator instance that can be iterated through easily to get each item in the ValidatorCollection collection.

适用于

另请参阅