Partilhar via


EventDescriptorCollection.Count Propriedade

Definição

Obtém o número de descritores de evento na coleção.

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

Valor da propriedade

O número de descritores de evento na coleção.

Implementações

Exemplos

O exemplo de código a seguir usa a Count propriedade para imprimir o número de eventos anexados a button1. Ele requer isso button1 e textBox1 foi instanciado em um formulário.

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

Comentários

A Count propriedade pode ser usada para definir os limites de um loop que itera por meio de uma coleção de objetos. Se a coleção for baseada em zero, certifique-se de usar Count - 1 como o limite superior do loop.

Observação

O HostProtectionAttribute atributo aplicado a essa classe tem o seguinte Resources valor de propriedade: Synchronization. Isso HostProtectionAttribute não afeta aplicativos da área de trabalho (que normalmente são iniciados clicando duas vezes em um ícone, digitando um comando ou inserindo uma URL em um navegador). Para obter mais informações, consulte a HostProtectionAttribute classe ou os atributos de programação e proteção de host do SQL Server.

Aplica-se a

Confira também