다음을 통해 공유


PropertyDescriptorCollection.Count 속성

정의

컬렉션의 속성 설명자 수를 가져옵니다.

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

적용 대상

추가 정보