PropertyDescriptorCollection.Count Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает количество дескрипторов свойств в коллекции.
public:
property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer
Значение свойства
Количество дескрипторов свойств в коллекции.
Реализации
Примеры
В следующем примере кода свойство используется Count для печати количества свойств.button1 Для этого требуется button1textBox1 создать экземпляр в форме.
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
Комментарии
Свойство можно использовать Count для задания ограничений цикла, который выполняет итерацию через коллекцию объектов. Так как коллекция основана на нулях, обязательно используйте Count - 1 в качестве верхней границы цикла.