PropertyDescriptorCollection.Count Свойство

Определение

Возвращает количество дескрипторов свойств в коллекции.

public:
 property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer

Значение свойства

Int32

Количество дескрипторов свойств в коллекции.

Реализации

Примеры

В следующем примере кода свойство используется Count для печати количества свойств в button1. Для этого требуется button1 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();
   }
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

Комментарии

Свойство можно использовать для Count задания ограничений цикла, который выполняет итерацию по коллекции объектов. Так как коллекция отсчитывается от нуля, обязательно используйте Count - 1 ее в качестве верхней границы цикла.

Применяется к

См. также раздел