AttributeCollection.Count Eigenschap
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee haalt u het aantal kenmerken op.
public:
property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer
Waarde van eigenschap
Het aantal kenmerken.
Implementeringen
Voorbeelden
In het volgende codevoorbeeld wordt de Count eigenschap gebruikt om het aantal eigenschappen button1 in een tekstvak af te drukken. Hierbij wordt ervan uitgegaan dat button1 en textBox1 zijn gemaakt op een formulier.
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
Opmerkingen
U kunt de Count eigenschap gebruiken om de limieten van een lus in te stellen die door een verzameling objecten wordt herhaald. Als de verzameling op nul is gebaseerd, moet u deze gebruiken Count - 1 als de bovengrens van de lus.