EventDescriptorCollection.Count Propiedad

Definición

Obtiene el número de descriptores de eventos de la colección.

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

Valor de propiedad

Número de descriptores de eventos de la colección.

Implementaciones

Ejemplos

En el ejemplo de código siguiente se usa la Count propiedad para imprimir el número de eventos adjuntos a button1. Requiere que button1 y textBox1 se hayan creado instancias en un formulario.

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

Comentarios

La Count propiedad se puede usar para establecer los límites de un bucle que recorre en iteración una colección de objetos . Si la colección está basada en cero, asegúrese de usar Count - 1 como límite superior del bucle.

Nota

El HostProtectionAttribute atributo aplicado a esta clase tiene el siguiente Resources valor de propiedad: Synchronization. El atributo HostProtectionAttribute no afecta a las aplicaciones de escritorio (que normalmente se inician haciendo doble clic en un icono, escribiendo un comando o introduciendo una dirección URL en el explorador). Para obtener más información, vea la HostProtectionAttribute clase o SQL Server Atributos de programación y protección de host.

Se aplica a

Consulte también