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

적용 대상

추가 정보