AttributeCollection.GetEnumerator 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
이 컬렉션의 열거자를 가져옵니다.
public:
System::Collections::IEnumerator ^ GetEnumerator();
public System.Collections.IEnumerator GetEnumerator();
member this.GetEnumerator : unit -> System.Collections.IEnumerator
Public Function GetEnumerator () As IEnumerator
반품
형식 IEnumerator의 열거자입니다.
예제
다음 코드 예제에서는 특성에 대한 button1열거자를 가져옵니다. 열거자를 사용하여 컬렉션에 있는 특성의 이름을 인쇄합니다. 폼에서 생성된 것으로 button1textBox1 가정합니다.
private:
void MyEnumerator()
{
// Creates a new collection and assigns it the attributes for button1.
AttributeCollection^ attributes;
attributes = TypeDescriptor::GetAttributes( button1 );
// Creates an enumerator for the collection.
System::Collections::IEnumerator^ ie = attributes->GetEnumerator();
// Prints the type of each attribute in the collection.
Object^ myAttribute;
System::Text::StringBuilder^ text = gcnew System::Text::StringBuilder;
while ( ie->MoveNext() )
{
myAttribute = ie->Current;
text->Append( myAttribute );
text->Append( '\n' );
}
textBox1->Text = text->ToString();
}
void MyEnumerator()
{
// Creates a new collection and assigns it the attributes for button1.
AttributeCollection attributes;
attributes = TypeDescriptor.GetAttributes(button1);
// Creates an enumerator for the collection.
System.Collections.IEnumerator ie = attributes.GetEnumerator();
// Prints the type of each attribute in the collection.
object myAttribute;
while (ie.MoveNext())
{
myAttribute = ie.Current;
textBox1.Text += myAttribute.ToString();
textBox1.Text += '\n';
}
}
Private Sub MyEnumerator
' Creates a new collection and assigns it the attributes for button1.
Dim attributes As AttributeCollection
attributes = TypeDescriptor.GetAttributes(button1)
' Creates an enumerator for the collection.
Dim ie As System.Collections.IEnumerator = attributes.GetEnumerator
' Prints the type of each attribute in the collection.
Dim myAttribute As Object
Do While ie.MoveNext
myAttribute = ie.Current
textBox1.Text = textBox1.Text & myAttribute.toString & ControlChars.crlf
Loop
End Sub