Share via


PropertyDescriptorCollection.Count Özellik

Tanım

Koleksiyondaki özellik tanımlayıcılarının sayısını alır.

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

Özellik Değeri

Koleksiyondaki özellik tanımlayıcılarının sayısı.

Uygulamalar

Örnekler

Aşağıdaki kod örneği, üzerindeki button1özellik sayısını yazdırmak için özelliğini kullanırCount. Bunun için bir textBox1 formda örnek oluşturulması gerekirbutton1.

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

Açıklamalar

bir nesne koleksiyonu aracılığıyla yineleyen bir döngünün sınırlarını ayarlamak için özelliğini kullanabilirsiniz Count . Koleksiyon sıfır tabanlı olduğundan döngünün üst sınırı olarak kullandığınızdan Count - 1 emin olun.

Şunlara uygulanır

Ayrıca bkz.