Condividi tramite


AttributeCollection.Count Proprietà

Definizione

Ottiene il numero di attributi.

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

Valore della proprietà

Numero di attributi.

Implementazioni

Esempio

Nell'esempio di codice seguente viene utilizzata la Count proprietà per stampare il numero di proprietà in button1 una casella di testo. Si presuppone che button1 e textBox1 siano stati creati in un modulo.

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

Commenti

È possibile utilizzare la Count proprietà per impostare i limiti di un ciclo che scorre un insieme di oggetti. Se la raccolta è in base zero, assicurarsi di usare Count - 1 come limite superiore del ciclo.

Si applica a

Vedi anche