AttributeCollection.Count Свойство

Определение

Возвращает количество атрибутов.

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

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

Количество атрибутов.

Реализации

Примеры

В следующем примере кода свойство используется Count для вывода количества свойств button1 в текстовом поле. Предполагается, что button1 и textBox1 были созданы в форме.

private:
   void GetCount()
   {
      // Creates a new collection and assigns it the attributes for button1.
      AttributeCollection^ attributes;
      attributes = TypeDescriptor::GetAttributes( button1 );
      
      // Prints the number of items in the collection.
      textBox1->Text = attributes->Count.ToString();
   }
private void GetCount() {
    // Creates a new collection and assigns it the attributes for button1.
    AttributeCollection attributes;
    attributes = TypeDescriptor.GetAttributes(button1);

    // Prints the number of items in the collection.
    textBox1.Text = attributes.Count.ToString();
 }
Private Sub GetCount
    ' Creates a new collection and assigns it the attributes for button 1.
    Dim attributes As AttributeCollection
    attributes = TypeDescriptor.GetAttributes(button1)
    ' Prints the number of items in the collection.
    textBox1.Text = attributes.Count.ToString
End Sub

Комментарии

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

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

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