Partager via


AttributeCollection.Count Propriété

Définition

Obtient le nombre d’attributs.

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

Valeur de propriété

Nombre d’attributs.

Implémente

Exemples

L’exemple de code suivant utilise la Count propriété pour imprimer le nombre de propriétés dans button1 une zone de texte. Il part du principe que button1 et textBox1 ont été créés sur un formulaire.

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

Remarques

Vous pouvez utiliser la Count propriété pour définir les limites d’une boucle qui itère dans une collection d’objets. Si la collection est basée sur zéro, veillez à utiliser Count - 1 comme limite supérieure de la boucle.

S’applique à

Voir aussi