PropertyDescriptorCollection.Count プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
コレクション内のプロパティ記述子の数を取得します。
public:
property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer
プロパティ値
コレクション内のプロパティ記述子の数。
実装
例
次のコード例では、 Count プロパティを使用して、 button1のプロパティの数を出力します。 フォームで button1 と textBox1 がインスタンス化されている必要があります。
private:
void GetCount()
{
// Creates a new collection and assign it the properties for button1.
PropertyDescriptorCollection^ properties = TypeDescriptor::GetProperties( button1 );
// Prints the number of properties on button1 in a textbox.
textBox1->Text = properties->Count.ToString();
}
void GetCount()
{
// Creates a new collection and assign it the properties for button1.
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);
// Prints the number of properties on button1 in a textbox.
textBox1.Text = properties.Count.ToString();
}
Private Sub GetCount()
' Creates a new collection and assign it the properties for button1.
Dim properties As PropertyDescriptorCollection = TypeDescriptor.GetProperties(button1)
' Prints the number of properties on button1 in a textbox.
textBox1.Text = properties.Count.ToString()
End Sub
注釈
Count プロパティを使用して、オブジェクトのコレクションを反復処理するループの制限を設定できます。 コレクションは 0 から始まるため、ループの上限として必ず Count - 1 を使用してください。