Re: string == and Equals
- From: "Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Thu, 24 Jan 2008 11:13:24 -0800
On Thu, 24 Jan 2008 10:59:00 -0800, Jon Skeet [C# MVP] <skeet@xxxxxxxxx> wrote:
And please, remind me again, why is it that the == operator doesn't just
automatically use Object.Equals()?
I'm sure there's a good reason, but it's escaping me at the moment. It
seems pretty relevant to the question though.
Good question. There are any number of interesting things you can do
with operator overloading, although I'm not sure of the merit of them.
I thought in C# you couldn't overload the == operator. That was the source of my confusion.
I don't know where I got that idea (maybe because the assignment operator can't be overloaded), but yes...I agree that given that == can be overloaded, you can't rely on it always calling Object.Equals(). I was under the mistaken impression that this was something the compiler could have implemented.
I guess that's the "good reason" to which I referred. :)
Pete
.
- References:
- string == and Equals
- From: Peter K
- Re: string == and Equals
- From: Peter K
- Re: string == and Equals
- From: Jon Skeet [C# MVP]
- Re: string == and Equals
- From: Peter Duniho
- Re: string == and Equals
- From: Jon Skeet [C# MVP]
- string == and Equals
- Prev by Date: Re: Using VisualBasic 6 Random Access Files in dotnet
- Next by Date: Re: about IndexOf
- Previous by thread: Re: string == and Equals
- Next by thread: Re: string == and Equals
- Index(es):
Relevant Pages
|