EventLogEntryCollection.Count Propriedade

Definição

Obtém o número de entradas no registo de eventos (isto é, o número de elementos na EventLogEntry coleção).

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

Valor de Propriedade

O número de entradas atualmente no registo de eventos.

Implementações

Exemplos

O exemplo seguinte demonstra como usar a Count propriedade para iterar através de um EventLogEntryCollection objeto.

// Create a new EventLog object.
EventLog myEventLog1 = new EventLog();
myEventLog1.Log = myLogName;
// Obtain the Log Entries of the Event Log
EventLogEntryCollection myEventLogEntryCollection = myEventLog1.Entries;
Console.WriteLine("The number of entries in 'MyNewLog' = " +
                        myEventLogEntryCollection.Count);
// Display the 'Message' property of EventLogEntry.
for (int i = 0; i < myEventLogEntryCollection.Count; i++)
{
    Console.WriteLine("The Message of the EventLog is :" +
                            myEventLogEntryCollection[i].Message);
}
' Create a new EventLog object.
Dim myEventLog1 As New EventLog()
myEventLog1.Log = myLogName
' Obtain the Log Entries of the Event Log
Dim myEventLogEntryCollection As EventLogEntryCollection = myEventLog1.Entries
Console.WriteLine("The number of entries in 'MyNewLog' = " + _
                           myEventLogEntryCollection.Count.ToString())
' Display the 'Message' property of EventLogEntry.
Dim i As Integer
For i = 0 To myEventLogEntryCollection.Count - 1
   Console.WriteLine("The Message of the EventLog is :" + _
                  myEventLogEntryCollection(i).Message)
Next i

Observações

An EventLogEntryCollection representa uma lista dinâmica de todas as entradas num registo. Assim, a Count propriedade pode mudar durante a vida útil da EventLogEntryCollection instância que cria. Normalmente, é melhor trabalhar diretamente com a Count propriedade em vez de atribuir o seu valor a uma variável.

Aplica-se a

Ver também