EventLogEntryCollection.Count EventLogEntryCollection.Count EventLogEntryCollection.Count EventLogEntryCollection.Count Property

Definizione

Ottiene il numero di voci nel log eventi (ovvero il numero di elementi all'interno dell'insieme EventLogEntry).Gets the number of entries in the event log (that is, the number of elements in the EventLogEntry collection).

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

Valore della proprietà

Numero di voci nel log eventi.The number of entries currently in the event log.

Implementazioni

Esempi

Nell'esempio seguente viene illustrato come utilizzare la Count proprietà per scorrere un EventLogEntryCollection oggetto.The following example demonstrates how to use the Count property to iterate through an EventLogEntryCollection object.

// Create a new EventLog object.
EventLog^ myEventLog1 = gcnew EventLog;
myEventLog1->Log = myLogName;

// Obtain the Log Entries of the Event Log
EventLogEntryCollection^ myEventLogEntryCollection = myEventLog1->Entries;
Console::WriteLine( "The number of entries in 'MyNewLog' = {0}", myEventLogEntryCollection->Count );

// Display the 'Message' property of EventLogEntry.
for ( int i = 0; i < myEventLogEntryCollection->Count; i++ )
{
   Console::WriteLine( "The Message of the EventLog is : {0}", myEventLogEntryCollection[ i ]->Message );
}
// 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

Commenti

Un EventLogEntryCollection oggetto rappresenta un elenco dinamico di tutte le voci di un log.An EventLogEntryCollection represents a dynamic list of all the entries in a log. Pertanto, la Count proprietà può essere modificata durante la durata EventLogEntryCollection dell'istanza creata.Therefore, the Count property can change during the lifetime of the EventLogEntryCollection instance that you create. In genere, è preferibile usare Count direttamente la proprietà anziché assegnare il relativo valore a una variabile.It is usually best to work with the Count property directly instead of assigning its value to a variable.

Si applica a

Vedi anche