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 de Propriedade

O número de atributos.

Implementações

Exemplos

O seguinte exemplo de código usa a Count propriedade para imprimir o número de propriedades numa button1 caixa de texto. Assume que button1 e textBox1 foram criados numa forma.

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

Observações

Podes usar a Count propriedade para definir os limites de um ciclo que itera através de uma coleção de objetos. Se a coleção for baseada em zero, certifique-se de usar Count - 1 como limite superior do laço.

Aplica-se a

Ver também