EventLogEntryCollection.Item[Int32] EventLogEntryCollection.Item[Int32] EventLogEntryCollection.Item[Int32] EventLogEntryCollection.Item[Int32] Property

Definizione

Ottiene una voce nel log eventi, in base a un indice che parte da 0 (zero).Gets an entry in the event log, based on an index that starts at 0 (zero).

public:
 virtual property System::Diagnostics::EventLogEntry ^ default[int] { System::Diagnostics::EventLogEntry ^ get(int index); };
public virtual System.Diagnostics.EventLogEntry this[int index] { get; }
member this.Item(int) : System.Diagnostics.EventLogEntry
Default Public Overridable ReadOnly Property Item(index As Integer) As EventLogEntry

Parametri

index
Int32 Int32 Int32 Int32

Indice in base zero associato alla voce del log eventi.The zero-based index that is associated with the event log entry.

Valore della proprietà

Voce del log eventi nella posizione specificata dal parametro index.The event log entry at the location that is specified by the index parameter.

Esempi

Nell'esempio seguente viene illustrato come visualizzare le informazioni relative agli elementi di EventLogEntryCollection un oggetto.The following example demonstrates how to display information for the items in 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

EventLogEntrygli oggetti vengono indicizzati dal sistema di log eventi in base all'ordine cronologico di arrivo nel registro eventi.EventLogEntry objects are indexed by the event log system according to the chronological order in which they arrived in the event log. Utilizzare la Item[Int32] proprietà per selezionare una voce del registro eventi specifica il cui indice nella raccolta è noto.Use the Item[Int32] property to select a specific event log entry whose index in the collection is known.

Scorrere l'istanza EventLogEntryCollection di ogni EventLogEntry oggetto in modo sequenziale.Iterating through the EventLogEntryCollection instance steps through each EventLogEntry object sequentially. La raccolta è dinamica e il numero di voci potrebbe non essere immutabile quando si immette il ciclo.The collection is dynamic and the number of entries may not be immutable when you enter the loop. Pertanto, è necessario utilizzare un for each...next ciclo anziché un for(int i=0; i<count, i++) ciclo per scorrere le voci associate EventLogEntryCollection all'istanza di per esaminare l'intero set di voci.Therefore, you should use a for each...next loop instead of a for(int i=0; i<count, i++) loop to step through entries that are associated with the EventLogEntryCollection instance to examine the entire set of entries.

Poiché le nuove voci vengono aggiunte all'elenco esistente, l'esecuzione nella raccolta consente di accedere alle voci create dopo la EventLogEntryCollectioncreazione iniziale di.Because new entries are appended to the existing list, stepping through the collection enables you to access the entries that were created after you originally created the EventLogEntryCollection.

Si applica a

Vedi anche