EventDescriptorCollection.Count Propriedade

Definição

Obtém o número de descritores de evento na coleção.Gets the number of event descriptors in the collection.

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

Valor da propriedade

Int32

O número de descritores de eventos na coleção.The number of event descriptors in the collection.

Implementações

Exemplos

O exemplo de código a seguir usa a Count propriedade para imprimir o número de eventos anexados a button1 .The following code example uses the Count property to print the number of events attached to button1. Ele requer que button1 e textBox1 tenha sido instanciado em um formulário.It requires that button1 and textBox1 have been instantiated on a form.

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();
   }
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();
 }

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.The Count property can be used to set the limits of a loop that iterates through a collection of objects. Se a coleção for baseada em zero, certifique-se de usar Count - 1 como o limite superior do loop.If the collection is zero-based, be sure to use Count - 1 as the upper boundary of the loop.

Observação

O HostProtectionAttribute atributo aplicado a essa classe tem o seguinte Resources valor de propriedade: Synchronization .The HostProtectionAttribute attribute applied to this class has the following Resources property value: Synchronization. HostProtectionAttribute não afeta aplicativos de área de trabalho (que são normalmente iniciados com o clique duplo em um ícone, a digitação de um comando ou a inserção de uma URL em um navegador).The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). Para obter mais informações, consulte a HostProtectionAttribute classe ou os atributos de proteção de host e de programação de SQL Server.For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

Aplica-se a

Confira também