Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Different between operator comparision and '.Equals(x)'

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anthony - 19 Jul 2006 21:12 GMT
Hi All,
  I would like to know what is the differnet between operator comparision
and '.Equals(x)'

Anthony
Barry Kelly - 19 Jul 2006 23:10 GMT
>    I would like to know what is the differnet between operator comparision
> and '.Equals(x)'

The '==' operator for reference types is by default a reference
comparison. Only if the two values refer to the same object does it
return true, unless it has been overloaded. If '==' has been overloaded,
the version of '==' called is statically determined at compile time
based on the 'operator ==' definitions on the two types involved (one on
each side of the '==').

By default, '==' isn't defined for value types (structs), unless you
define one yourself.

The Equals method is virtual, and thus is selected by dynamic dispatch
at runtime. By default, it also performs a reference comparison, but it
may be overloaded. By the way, to ease the complications of checking for
null and avoiding calling Equals on a null reference, you can use
object.Equals(object,object) to call Equals and it can take care of
those details.

-- Barry

Signature

http://barrkel.blogspot.com/

Anthony - 20 Jul 2006 14:16 GMT
Thanks Barry, This is very helpful.

> >    I would like to know what is the differnet between operator comparision
> > and '.Equals(x)'
[quoted text clipped - 17 lines]
>
> -- Barry

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.