AttributeCollection.Count Propriedade

Definição

Obtém o número de atributos.

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

Valor da propriedade

O número de atributos.

Implementações

Exemplos

O exemplo de código a seguir usa a Count propriedade para imprimir o número de propriedades em button1 uma caixa de texto. Ele pressupõe que button1 e textBox1 tenham sido criados em um formulário.

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();
   }
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();
 }
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

Comentários

Você pode usar a Count propriedade para definir os limites de um loop que itera por meio de uma coleção de objetos . Se a coleção for baseada em zero, use Count - 1 como o limite superior do loop.

Aplica-se a

Confira também