PropertyDescriptorCollection.Count Eigenschaft

Definition

Ruft die Anzahl der Eigenschaftenbezeichner 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

Int32

Die Anzahl der Eigenschaftenbezeichner in der Auflistung.

Implementiert

Beispiele

Im folgenden Codebeispiel wird die Eigenschaft verwendet, um die Count Anzahl der Eigenschaften auf button1zu drucken. Es erfordert, dass button1 textBox1 sie auf einem Formular instanziiert wurde.

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

Hinweise

Sie können die Count Eigenschaft verwenden, um die Grenzwerte einer Schleife festzulegen, die durch eine Auflistung von Objekten durchläuft. Da die Auflistung nullbasiert ist, müssen Sie die obere Grenze der Schleife verwenden Count - 1 .

Gilt für

Siehe auch