PropertyDescriptorCollection.IDictionary.GetEnumerator Method

Definition

Returns an enumerator for this class.

C#
System.Collections.IDictionaryEnumerator IDictionary.GetEnumerator();

Returns

An enumerator of type IEnumerator.

Implements

Examples

The following code example gets an enumerator for the properties on button1. It uses the enumerator to print the names of the properties in the collection. It requires that button1 and textBox1 have been instantiated on a form.

C#
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()) {
      myProperty = ie.Current;
      textBox1.Text += myProperty.ToString() + '\n';
   }
}

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

See also