Share via


AttributeCollection.Count Vlastnost

Definice

Získá počet atributů.

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

Hodnota vlastnosti

Počet atributů.

Implementuje

Příklady

Následující příklad kódu používá Count vlastnost k vytištění počtu vlastností button1 v textovém poli. Předpokládá, že button1 a textBox1 byly vytvořeny ve formuláři.

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

Poznámky

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

Platí pro

Viz také