Sdílet prostřednictvím


EventLogEntryCollection.Count Vlastnost

Definice

Získá počet položek v protokolu událostí (to znamená počet prvků v kolekci EventLogEntry ).

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

Hodnota vlastnosti

Počet položek aktuálně v protokolu událostí.

Implementuje

Příklady

Následující příklad ukazuje, jak použít Count vlastnost iterovat prostřednictvím objektu EventLogEntryCollection .

// 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

Poznámky

Představuje EventLogEntryCollection dynamický seznam všech položek v protokolu. Count Vlastnost se proto může změnit během životnosti EventLogEntryCollection instance, kterou vytvoříte. Obvykle je nejlepší pracovat s Count vlastností přímo místo přiřazení její hodnoty proměnné.

Platí pro

Viz také