PropertyDescriptorCollection.IDictionary.GetEnumerator 方法

定义

返回该类的枚举数。

 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

返回

IEnumerator 类型的枚举数。

实现

示例

下面的代码示例获取 上 button1属性的枚举器。 它使用 枚举器打印集合中属性的名称。 它要求 button1 已在窗体上实例化和 textBox1

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

适用于

另请参阅