AttributeCollection.Count Właściwość
Definicja
Pobiera liczbę atrybutów.Gets the number of attributes.
public:
property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer
Wartość właściwości
Liczba atrybutów.The number of attributes.
Implementuje
Przykłady
Poniższy przykład kodu używa właściwości, Count Aby drukować liczbę właściwości w button1
polu tekstowym.The following code example uses the Count property to print the number of properties on button1
in a text box. Przyjęto założenie, że button1
i zostały textBox1
utworzone w formularzu.It assumes that button1
and textBox1
have been created on a form.
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
Uwagi
Możesz użyć właściwości, Count Aby ustawić limity pętli, która iteruje przez kolekcję obiektów.You can use the Count property to set the limits of a loop that iterates through a collection of objects. Jeśli kolekcja jest oparta na wartości zero, pamiętaj, aby użyć Count - 1
jako górnej granicy pętli.If the collection is zero-based, be sure to use Count - 1
as the upper boundary of the loop.