다음을 통해 공유


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 합니다.

적용 대상

추가 정보