AttributeCollection.GetEnumerator Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Recebe um enumerador para esta coleção.
public:
System::Collections::IEnumerator ^ GetEnumerator();
public System.Collections.IEnumerator GetEnumerator();
member this.GetEnumerator : unit -> System.Collections.IEnumerator
Public Function GetEnumerator () As IEnumerator
Devoluções
Um enumerador do tipo IEnumerator.
Exemplos
O seguinte exemplo de código obtém um enumerador para os atributos em button1. Utiliza o enumerador para imprimir os nomes dos atributos na coleção. Assume que button1 e textBox1 foram criados numa forma.
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