Hello Everybody!
I try to construct a method that searches for an EventID in EventLog. If it finds the value it return false, if not it returns true. The problem is the method has an error ..."return result" use of unassigned local variable 'result'. Any ideas how to fix this? Thanks!
I try to construct a method that searches for an EventID in EventLog. If it finds the value it return false, if not it returns true. The problem is the method has an error ..."return result" use of unassigned local variable 'result'. Any ideas how to fix this? Thanks!
public static bool EventLog() { bool result; EventLog log = new EventLog(); log.Log = "System"; foreach (EventLogEntry ev in log.Entries) { if (ev.InstanceId.Equals("7034")) { result = false; } else { result = true; } } return result; }