Miscellaneous Debris

Avner Kashtan's Frustrations and Exultations

System.Diagnostics.EventLogEntry and the non-equal Equals.

Just a quick heads-up in case you're stumped with this problem, or just passing by:

The System.Diagnostics.EventLogEntry class implements the Equals method to check if two entries are identical, even if they're not the same instance. However, contrary to best practices, it does NOT overload the operator==, so these two bits of code will behave differently:

EventLog myEventLog = new EventLog("Application");
EventLogEntry entry1 = myEventLog.Entries[0];
EventLogEntry entry2 = myEventLog.Entries[0];

bool correct = entry1.Equals(entry2);
bool incorrect = entry1 == entry2;

After running this code, correct will be true while incorrect will be false.

Good to know, if you're reading event logs in your code.

Comments

AndrewSeven said:

Some are just more equal than others :P

# November 26, 2007 9:31 AM

Brian Dukes said:

Just for the record,from msdn2.microsoft.com/.../7h9bszxx(vs.80).aspx:

"Most reference types, even those that implement the Equals method, should not override ==."

# November 26, 2007 3:48 PM

Avner Kashtan said:

Andrew: Man, I should have used that one. It was just lying there waiting for me, and I missed it. :)

# November 26, 2007 3:50 PM

Katie Rodriguez said:

Really great article you got here. It'd be really cool to read a bit more about such theme. Thnx for sharing this data.

Katie Rodriguez

<a href="www.waybiz.com/">Finding supplier</a>

# May 3, 2010 7:05 PM

Whitny Stone said:

It was extremely interesting for me to read that article. Thanks for it. I like such themes and anything that is connected to them. I definitely want to read more soon.    

Whitny  Stone    

<a href="www.latinescortlondon.com/">London escorts latin</a>

# February 26, 2011 1:39 PM

Natasha Swift said:

It is rather interesting for me to read this article. Thanks for it. I like such topics and everything that is connected to this matter. I definitely want to read a bit more on that blog soon.        

Natasha  Swift        

<a href="www.phone-blocker.com/">jammers for sale</a>

# March 24, 2011 2:42 PM

Anete Simpson said:

It was rather interesting for me to read that post. Thanks the author for it. I like such topics and anything connected to this matter. I definitely want to read more soon.

Anete Simpson    

<a href="milanescorts.com/">escort girls a milano</a>

# March 26, 2011 2:49 AM

Katty Karver said:

It is extremely interesting for me to read the blog. Thanks for it. I like such topics and anything that is connected to them. I definitely want to read a bit more on this site soon.            

Katty  Karver          

<a href="www.baccaratgirls.com/">london escorts credit card</a>

# April 16, 2011 11:40 AM

Sara Flouee said:

It was extremely interesting for me to read that post. Thanx for it. I like such themes and everything that is connected to this matter. I would like to read a bit more on this site soon.            

Sara  Flouee            

<a href="monacoescort.com/">girl monaco</a>

# April 26, 2011 12:50 PM

Moncler said:

This is a Professional blog,great you can write so beautiful.

# December 14, 2011 8:15 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)