PropertyDescriptorCollection.Count Właściwość
Definicja
Pobiera liczbę deskryptorów właściwości w kolekcji.Gets the number of property descriptors in the collection.
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 deskryptorów właściwości w kolekcji.The number of property descriptors in the collection.
Implementuje
Przykłady
Poniższy przykład kodu używa właściwości, Count Aby wydrukować liczbę właściwości button1
.The following code example uses the Count property to print the number of properties on button1
. Wymaga, aby button1
i zostały textBox1
utworzone na formularzu.It requires that button1
and textBox1
have been instantiated on a form.
private:
void GetCount()
{
// Creates a new collection and assign it the properties for button1.
PropertyDescriptorCollection^ properties = TypeDescriptor::GetProperties( button1 );
// Prints the number of properties on button1 in a textbox.
textBox1->Text = properties->Count.ToString();
}
private void GetCount() {
// Creates a new collection and assign it the properties for button1.
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);
// Prints the number of properties on button1 in a textbox.
textBox1.Text = properties.Count.ToString();
}
Private Sub GetCount()
' Creates a new collection and assign it the properties for button1.
Dim properties As PropertyDescriptorCollection = TypeDescriptor.GetProperties(button1)
' Prints the number of properties on button1 in a textbox.
textBox1.Text = properties.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. Ponieważ kolekcja jest oparta na zero, należy użyć Count - 1
jako górnej granicy pętli.Because the collection is zero-based, be sure to use Count - 1
as the upper boundary of the loop.