Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Method to Search Event ID in EventLog

$
0
0
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!
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;
        }




Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>