Hi,
What is the difference between Object.Equals and "==" operator ?
When we use CollectionBase.List.Remove(object), which methods is used to
compare objects ?
Thanks 4 6631
For interest, there are also performance differences between instance and
static(shared) methods for Equals and the == operator when comparing
strings.
" #Hai" <Re******************@Softhome.net> wrote in message
news:ek**************@TK2MSFTNGP11.phx.gbl... Hi, What is the difference between Object.Equals and "==" operator ? When we use CollectionBase.List.Remove(object), which methods is used to compare objects ?
Thanks
Hi Anthony!
Can you tell me more about the performance differences. Which way is
fastest?
TIA,
Markus
"Anthony Bouch" <to**@nospamforever.com> schrieb im Newsbeitrag
news:e2**************@TK2MSFTNGP10.phx.gbl... For interest, there are also performance differences between instance and static(shared) methods for Equals and the == operator when comparing strings.
" #Hai" <Re******************@Softhome.net> wrote in message news:ek**************@TK2MSFTNGP11.phx.gbl... Hi, What is the difference between Object.Equals and "==" operator ? When we use CollectionBase.List.Remove(object), which methods is used to compare objects ?
Thanks
Furthermore, not all languages support operator overloading. So, if one
wants to write language independent code she/he should not rely on operator
overloading. For c# convenince the operators might be overloaded and the
virtual method might be used internally.
B/rgds
100
"Jon Skeet" <sk***@pobox.com> wrote in message
news:MP************************@news.microsoft.com ... [What does this have to do with Windows forms, by the way? Please limit your post to relevant groups - preferrably only one!]
#Hai <Re******************@Softhome.net> wrote: What is the difference between Object.Equals and "==" operator ?
Operators are not applied polymorphically, methods are. For instance:
string x = "hello"; string y = new string (x.ToCharArray());
object a=x; object b=y;
x==y; // True, because String== is applied a==b; // False, because Object== is applied, which asserts reference // identity
x.Equals(y); // True, because String.Equals override Object.Equals a.Equals(b); // True, because methods are invoked polymorphically
When we use CollectionBase.List.Remove(object), which methods is used to compare objects ?
Almost certainly Equals - it's the only way that makes sense, really, given that CollectionBase only knows about Objects, so to remove entries you'd have to have the exact reference if it used ==.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet/ If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Arno Huetter |
last post by:
Hi there,
I try to execute a DB-Update using
ADO.NET CommandBuilder (MSORA Data Provider) on Oracle 8.1.6
(unfortunately, ODP.NET seems to require Oracle 9i or above). One of
ADO.NET's...
|
by: ambar.shome |
last post by:
Dear All,
Whats the difference between a copy constructor and assignment
operator. We can assign the values of member variables of one object to
another object of same type using both of them....
|
by: Chris |
last post by:
This is something that has been bugging me for some time. When exactly
should I be using == instead of .Equals() ?
I see a lot of code that performs object evaluation e.g. Is Object1 the
same as...
|
by: Roger |
last post by:
What did MS not take the chance to change
the silly == operator when they designed C#,
to something reasonable like = ?
Why change the universal meaning of = ?
Wouldn't it be better to have:...
|
by: Klaus Löffelmann |
last post by:
Hi,
maybe it's already too late, but what is the deal with overwriting
Object.Equals.
I have to use "overrides overloads" to really overwrite the correct
'version' of equals, even if a single...
|
by: Rich |
last post by:
Hello,
Just checking which is more efficient/better/or correct
Do While something
str1 = dr(i).ToString
If Not str1.Equals("xyz") Then
....
or
|
by: Rob |
last post by:
The code below is almost there (it does change the value for EVERY
ORDER)....
I simply want to be able to change the value of the Delivered Tag to Yes.
BUT ONLY if the Order is equal to 123456 ?
...
|
by: Phil Davidson |
last post by:
/*
(Posted to microsoft.public.dotnet.languages.vc)
In C++/CLI under Visual Studio 2005, creating an "enum class" member
called "Equals" can cause compiler error C1060 (out of memory) and C1063...
|
by: screechyboy |
last post by:
OKay so im new to Javascript Cookies....
I am able to set and return cookie values but i know want to create an
if statement!
One of my cookies is called "color" and i wish to write a script...
|
by: Java script Dude |
last post by:
Greetings,
Now I can understand that 0 equal false, but should "" also equal
false?
Apparently the answer is yes. When I test both Firefox and IE, they
both say ""==false . I assume this goes...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |