PropertyDescriptorCollection.GetEnumerator 메서드

정의

이 클래스의 열거자를 반환합니다.

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

반품

형식 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() )
      {
         myProperty = ie->Current;
         textBox1->Text = textBox1->Text + myProperty + "\n";
      }
   }
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';
    }
}
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

적용 대상

추가 정보