다음을 통해 공유


EventLogEntryCollection.Count 속성

정의

이벤트 로그의 항목 수(즉, 컬렉션의 요소 EventLogEntry 수)를 가져옵니다.

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

속성 값

이벤트 로그에 현재 있는 항목 수입니다.

구현

예제

다음 예제에서는 개체를 반복 하는 속성을 사용 Count 하는 방법을 보여 줍니다 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

설명

로그 EventLogEntryCollection 에 있는 모든 항목의 동적 목록을 나타냅니다. 따라서 Count 만든 인스턴스의 수명 동안 속성이 EventLogEntryCollection 변경 될 수 있습니다. 일반적으로 변수에 값을 할당하는 대신 속성으로 Count 직접 작업하는 것이 가장 좋습니다.

적용 대상

추가 정보