Freigeben über


AttributeCollection.Count Eigenschaft

Definition

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

Implementiert

Beispiele

Im folgenden Codebeispiel wird die Count Eigenschaft verwendet, um die Anzahl der Eigenschaften button1 in einem Textfeld zu drucken. Es wird davon ausgegangen, dass button1 und textBox1 auf einem Formular erstellt wurden.

private:
   void GetCount()
   {
      // Creates a new collection and assigns it the attributes for button1.
      AttributeCollection^ attributes;
      attributes = TypeDescriptor::GetAttributes( button1 );
      
      // Prints the number of items in the collection.
      textBox1->Text = attributes->Count.ToString();
   }
void GetCount()
{
    // Creates a new collection and assigns it the attributes for button1.
    AttributeCollection attributes;
    attributes = TypeDescriptor.GetAttributes(button1);

    // Prints the number of items in the collection.
    textBox1.Text = attributes.Count.ToString();
}
Private Sub GetCount
    ' Creates a new collection and assigns it the attributes for button 1.
    Dim attributes As AttributeCollection
    attributes = TypeDescriptor.GetAttributes(button1)
    ' Prints the number of items in the collection.
    textBox1.Text = attributes.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. Wenn die Auflistung nullbasiert ist, stellen Sie sicher, dass sie als oberer Rand der Schleife verwendet Count - 1 wird.

Gilt für:

Weitere Informationen