I want to delete the entry in every iteration. can I do it? Here is my code
static zero main (string [] arg) {el = new EventLog (); El.Log = "XMLWatcherLog"; El.Source = "XMLWatcherSource"; String netStr = string.Empty; Foreach (EventLogEntry entry in el.Entries) {netStr + = "& lt; Items" + "& Lt; Path & gt;" + Entry. Message + "& lt; / path & gt;"; // I want to delete the entry here}}
I think that you have foreach Should not be used because you are going to modify the list (delete the entry). The first walk will work fine for the code, but at the second instance it will throw the exception that 'the collection was modified' instead of the foreigner you can make simple use for the loop.
Comments
Post a Comment