PropertyDescriptorCollection.GetEnumerator Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns an enumerator for this class.
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
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.
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";
}
}
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';
}
}
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
Applies to
See also
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET