Sdílet prostřednictvím


EventDescriptorCollection.Count Vlastnost

Definice

Získá počet popisovačů událostí v kolekci.

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

Hodnota vlastnosti

Počet popisovačů událostí v kolekci.

Implementuje

Příklady

Následující příklad kódu používá Count vlastnost k tisku počtu událostí připojených k button1. Vyžaduje vytvoření button1 instance formuláře textBox1 .

private:
   void GetCount()
   {
      // Creates a new collection and assigns it the events for button1.
      EventDescriptorCollection^ events = TypeDescriptor::GetEvents( button1 );
      
      // Prints the number of events on button1 in a text box.
      textBox1->Text = events->Count.ToString();
   }
void GetCount()
{
    // Creates a new collection and assigns it the events for button1.
    EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);

    // Prints the number of events on button1 in a text box.
    textBox1.Text = events.Count.ToString();
}
Private Sub GetCount()
    ' Creates a new collection and assigns it the events for button1.
    Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(button1)
    
    ' Prints the number of events on button1 in a text box.
    textBox1.Text = events.Count.ToString()
End Sub

Poznámky

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

Poznámka:

Atribut HostProtectionAttribute použitý pro tuto třídu má následující Resources hodnotu vlastnosti: Synchronization. Nemá HostProtectionAttribute vliv na desktopové aplikace (které se obvykle spouští poklikáním na ikonu, zadáním příkazu nebo zadáním adresy URL v prohlížeči). Další informace naleznete v HostProtectionAttribute tématu třídy nebo programování SYSTÉMU SQL Server a atributy ochrany hostitele.

Platí pro

Viz také