共用方式為


BindingContext.IEnumerable.GetEnumerator 方法

定義

取得此集合的列舉值。

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

傳回

IEnumerator

集合的 IEnumerator

實作

範例

下列程式碼範例會 IEnumerable.GetEnumerator 使用 方法傳回 IEnumeratorBindingContext

private:
   void GetManagerEnumerator()
   {
      IEnumerator^ myEnumerator;
      myEnumerator = ( (IEnumerable^)(this->BindingContext) )->GetEnumerator();
      ForEachEnumerator();
   }

   void ForEachEnumerator()
   {
      for each ( IEnumerator^ myEnumerator in ( (IEnumerable^)(this->BindingContext) ) )
      {
         Console::WriteLine( myEnumerator );
      }
   }
private void GetManagerEnumerator(){
   IEnumerator myEnumerator;
   myEnumerator = ((IEnumerable)this.BindingContext).GetEnumerator();
   ForEachEnumerator();
}

private void ForEachEnumerator(){
   foreach( IEnumerator myEnumerator in this.BindingContext){
      Console.WriteLine(myEnumerator.ToString());
   }
}
Private Sub GetManagerEnumerator()
   Dim myEnumerator As IEnumerator
   myEnumerator = CType(BindingContext,IEnumerable).GetEnumerator()
   ForEachEnumerator()
End Sub

Private Sub ForEachEnumerator()
   Dim myEnumerator As IEnumerator
   For Each myEnumerator In CType(BindingContext,IEnumerable)
      Console.WriteLine(myEnumerator.Current.ToString())
   Next
End Sub

備註

IEnumerator方法傳回的 IEnumerable.GetEnumerator 可讓您逐一查看 所 BindingContext 管理的集合。

適用於