PropertyDescriptorCollection.IDictionary.GetEnumerator Methode

Definition

Gibt einen Enumerator für diese Klasse zurück.

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

Gibt zurück

Ein Enumerator vom Typ IEnumerator.

Implementiert

Beispiele

Im folgenden Codebeispiel wird ein Enumerator für die Eigenschaften von button1abgerufen. Es verwendet den Enumerator, um die Namen der Eigenschaften in der Auflistung zu drucken. Es erfordert, dass und button1textBox1 auf einem Formular instanziiert wurde.

private:
   void MyEnumerator()
   {
      // Creates a new collection and assigns it the properties for button1.
      PropertyDescriptorCollection^ properties = TypeDescriptor::GetProperties( button1 );
      
      // Creates an enumerator.
      IEnumerator^ ie = properties->GetEnumerator();
      
      // Prints the name of each property in the collection.
      Object^ myProperty;
      while ( ie->MoveNext() == true )
      {
         myProperty = ie->Current;
         textBox1->Text = textBox1->Text + myProperty + "\n";
      }
   }
private void MyEnumerator() {
   // Creates a new collection and assigns it the properties for button1.
   PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);

   // Creates an enumerator.
   IEnumerator ie = properties.GetEnumerator();

   // Prints the name of each property in the collection.
   Object myProperty;
   while(ie.MoveNext()==true) {
      myProperty = ie.Current;
      textBox1.Text += myProperty.ToString() + '\n';
   }
}
Private Sub MyEnumerator()
    ' Creates a new collection and assigns it the properties for button1.
    Dim properties As PropertyDescriptorCollection = _
       TypeDescriptor.GetProperties(button1)
       
    ' Creates an enumerator.
    Dim ie As IEnumerator = properties.GetEnumerator()
       
    ' Prints the name of each property in the collection.
    Dim myProperty As Object
    While ie.MoveNext() = True
        myProperty = ie.Current
        textBox1.Text &= myProperty.ToString() & ControlChars.Cr
    End While
End Sub

Gilt für:

Weitere Informationen