AttributeCollection.Count Tulajdonság
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Lekéri az attribútumok számát.
public:
property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer
Tulajdonság értéke
Az attribútumok száma.
Megvalósítás
Példák
Az alábbi példakód a Count tulajdonság használatával nyomtatja ki a tulajdonságok button1 számát egy szövegmezőben. Ezt feltételezi, button1 és textBox1 egy űrlapon lett létrehozva.
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
Megjegyzések
A tulajdonság használatával Count beállíthatja egy objektumgyűjteményen keresztül iterálható hurkok korlátait. Ha a gyűjtemény nulla alapú, mindenképpen használja Count - 1 a hurok felső határaként.