Redigera

Dela via


PropertyDescriptorCollection.Count Property

Definition

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

Property Value

The number of property descriptors in the collection.

Implements

Examples

The following code example uses the Count property to print the number of properties on button1. 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

Remarks

You can use the Count property to set the limits of a loop that iterates through a collection of objects. Because the collection is zero-based, be sure to use Count - 1 as the upper boundary of the loop.

Applies to

See also