このコレクションの列挙子を取得します。
Public Function GetEnumerator() As IEnumerator
[C#]
public IEnumerator GetEnumerator();
[C++]
public: IEnumerator* GetEnumerator();
[JScript]
public function GetEnumerator() : IEnumerator;
戻り値
IEnumerator 型の列挙子。
使用例
[Visual Basic, C#, C++] button1
の属性の列挙子を取得する例を次に示します。この例では、列挙子を使用してコレクション内の属性の名前を出力します。この例は、フォーム上に button1
と textBox1
が作成されていることを前提としています。
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
[C#]
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';
}
}
[C++]
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 = new System::Text::StringBuilder();
while ( ie->MoveNext() == true )
{
myAttribute = ie->Current;
text->Append( myAttribute );
text->Append( '\n' );
}
textBox1->Text = text->ToString();
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
参照
AttributeCollection クラス | AttributeCollection メンバ | System.ComponentModel 名前空間 | Attribute | IEnumerator