PropertyDescriptorCollection.Count Vlastnost
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Získá počet popisovačů vlastností v kolekci.
public:
property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer
Hodnota vlastnosti
Počet popisovačů vlastností v kolekci.
Implementuje
Příklady
Následující příklad kódu používá Count vlastnost k vytištění počtu vlastností na button1. Vyžaduje vytvoření button1 instance formuláře textBox1 .
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();
}
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
Poznámky
Vlastnost můžete použít Count k nastavení omezení smyčky, která iteruje prostřednictvím kolekce objektů. Vzhledem k tomu, že kolekce je založená na nule, nezapomeňte ji použít Count - 1 jako horní hranici smyčky.