AttributeCollection.GetEnumerator-Methode
Ruft einen Enumerator für diese Auflistung ab.
Namespace: System.ComponentModel
Assembly: System (in system.dll)
Syntax
'Declaration
Public Function GetEnumerator As IEnumerator
'Usage
Dim instance As AttributeCollection
Dim returnValue As IEnumerator
returnValue = instance.GetEnumerator
public IEnumerator GetEnumerator ()
public:
IEnumerator^ GetEnumerator ()
public IEnumerator GetEnumerator ()
public function GetEnumerator () : IEnumerator
Rückgabewert
Ein Enumerator vom Typ IEnumerator.
Beispiel
Im folgenden Codebeispiel wird ein Enumerator für die Attribute von button1
abgerufen. Mit dem Enumerator werden die Namen der Attribute in der Auflistung ausgegeben. Dabei wird vorausgesetzt, dass button1
und textBox1
in einem Formular erstellt wurden.
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
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;
while(ie.MoveNext()==true) {
myAttribute = ie.Current;
textBox1.Text += myAttribute.ToString();
textBox1.Text += '\n';
}
}
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() == true )
{
myAttribute = ie->Current;
text->Append( myAttribute );
text->Append( '\n' );
}
textBox1->Text = text->ToString();
}
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;
while ((ie.MoveNext() == true)) {
myAttribute = ie.get_Current();
textBox1.set_Text(textBox1.get_Text() + myAttribute.ToString());
textBox1.set_Text(textBox1.get_Text() + '\n');
}
} //MyEnumerator
private function MyEnumerator() {
// Creates a new collection and assigns it the attributes for button1.
var attributes : AttributeCollection;
attributes = TypeDescriptor.GetAttributes(button1);
// Creates an enumerator for the collection.
var ie : System.Collections.IEnumerator = attributes.GetEnumerator();
// Prints the type of each attribute in the collection.
var myAttribute;
while(ie.MoveNext()==true) {
myAttribute = ie.Current;
textBox1.Text += myAttribute.ToString();
textBox1.Text += '\n';
}
}
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
AttributeCollection-Klasse
AttributeCollection-Member
System.ComponentModel-Namespace
Attribute
IEnumerator