PropertyDescriptorCollection.Count Eigenschap

Definitie

Hiermee haalt u het aantal eigenschapsdescriptors op in de verzameling.

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

Waarde van eigenschap

Het aantal eigenschapsdescriptors in de verzameling.

Implementeringen

Voorbeelden

In het volgende codevoorbeeld wordt de Count eigenschap gebruikt om het aantal eigenschappen op button1af te drukken. Hiervoor moet button1 een formulier worden geïnstantieerd en textBox1 geïnstantieerd.

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

Opmerkingen

U kunt de Count eigenschap gebruiken om de limieten van een lus in te stellen die door een verzameling objecten wordt herhaald. Omdat de verzameling op nul is gebaseerd, moet u deze gebruiken Count - 1 als de bovengrens van de lus.

Van toepassing op

Zie ook