Freigeben über


PropertyDescriptorCollection.Count Eigenschaft

Definition

Ruft die Anzahl der Eigenschaftendeskriptoren in der Auflistung ab.

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

Eigenschaftswert

Die Anzahl der Eigenschaftendeskriptoren in der Auflistung.

Implementiert

Beispiele

Im folgenden Codebeispiel wird die Count Eigenschaft verwendet, um die Anzahl der Eigenschaften zu drucken.button1 Dies erfordert button1 und textBox1 wurde auf einem Formular instanziiert.

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

Hinweise

Mit der Count Eigenschaft können Sie die Grenzwerte einer Schleife festlegen, die durch eine Auflistung von Objekten durchlaufen wird. Da die Auflistung nullbasiert ist, müssen Sie sie unbedingt als oberer Rand der Schleife verwenden Count - 1 .

Gilt für:

Weitere Informationen