PropertyDescriptorCollection.Count Vlastnost

Definice

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, aby button1 se textBox1 ve formuláři vytvořily instance.

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

Poznámky

Vlastnost můžete použít Count k nastavení limitů smyčky, která iteruje kolekci objektů. Vzhledem k tomu, že kolekce je založená na nule, nezapomeňte použít Count - 1 jako horní hranici smyčky.

Platí pro

Viz také