Filter data for last 24 hours using c#?
<p>Here i am calculating the server restart count.</p>

<p>i need the server restart count for last 24 hours.</p>

<pre><code>string logType = "System";
EventLog ev = new EventLog(logType, System.Environment.MachineName);    
int count=0;
for (int i = ev.Entries.Count - 1; i &gt;= 0; i--)
{
EventLogEntry CurrentEntry = ev.Entries[i];
if (CurrentEntry.Source.ToUpper() == "USER32")
{
count = count + 1;
}
}
ev.Close();
</code></pre>

<p>and i have tried like</p>

<pre><code>DateTime dt = DateTime.Now;
TimeSpan ts = dt.Subtract(CurrentEntry.TimeGenerated);
int hours = (ts.Days * 24) + ts.Hours;
</code></pre>

<p>Any suggestion?</p>
