次の方法で共有


AttributeCollection.Count プロパティ

定義

属性の数を取得します。

public:
 property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer

プロパティ値

属性の数。

実装

次のコード例では、 Count プロパティを使用して、テキスト ボックス内の button1 のプロパティの数を出力します。 フォームに button1textBox1 が作成されていることを前提としています。

private:
   void GetCount()
   {
      // Creates a new collection and assigns it the attributes for button1.
      AttributeCollection^ attributes;
      attributes = TypeDescriptor::GetAttributes( button1 );
      
      // Prints the number of items in the collection.
      textBox1->Text = attributes->Count.ToString();
   }
void GetCount()
{
    // Creates a new collection and assigns it the attributes for button1.
    AttributeCollection attributes;
    attributes = TypeDescriptor.GetAttributes(button1);

    // Prints the number of items in the collection.
    textBox1.Text = attributes.Count.ToString();
}
Private Sub GetCount
    ' Creates a new collection and assigns it the attributes for button 1.
    Dim attributes As AttributeCollection
    attributes = TypeDescriptor.GetAttributes(button1)
    ' Prints the number of items in the collection.
    textBox1.Text = attributes.Count.ToString
End Sub

注釈

Count プロパティを使用して、オブジェクトのコレクションを反復処理するループの制限を設定できます。 コレクションが 0 から始まる場合は、ループの上限として Count - 1 を使用してください。

適用対象

こちらもご覧ください