473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Why is there no Equals() or GetHashCode() in ArrayList?

Why doesnt ArrayList implements the Equals() or GetHashCode() methods?
How is the developer supposed to check if an array list is equal to
another array list? Is the developer supposed to iterate through the
array list to find out if they are equal or not? This should be handled
by the framework classes and I don't want to do any unnecessary
implementation (read copy-paste-problems).

If I look through the other classes in System.Collection I see that no
implements GetHashCode() or Equals(). If none of them do, then it must
be a design choice. But what design choice would that be? If anyone
have any explanation, please let me know.I really want to know.

There is an interface in System.Collections.Generic that is named
IEqualityComparer, which has two methods, Equals() and GetHashCode().
Why make an interface when every class implements those methods? And
why doesn't the default list/collection classes implement this
interface?
<flamebait-to-be-ignored>
If I look to Java, the ArrayList implements equals(), hashCode() as all
good objects should. They have also a good explanation on how it is
done here.
http://shorl.com/gogedrikekati
http://shorl.com/fygafrebrypeko
</flamebait-to-be-ignored>

Regards
http://redsolo.blogspot.com

Nov 27 '06 #1
1 1949
Sorry for the double post into this group. This message was intended
for microsoft.public.dotnet.framework. Please reply to the message in
that group.

Sorry

Nov 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bijay Kumar | last post by:
Hi Guys, I was going through the source code of Object.cs in rotor. What I found is Equals() implemented as follows: public extern virtual bool Equals(Object obj); What I don't...
5
by: songie D | last post by:
I have a collection class that contains objects of the type of another class call it Class1, that I have created. The constructor for Class1 takes two integers These go on to be fields of the...
15
by: Rhy Mednick | last post by:
I have a class (let's call it ClassA) that I've written which has events. In another class (let's call it ClassB) I create a collection of ClassA objects. In a third class (ClassC) I create a...
3
by: cmrchs | last post by:
Hi, why is it requested that when Equals() is implemented in a class that GethashCode() must be implemented as well ? thnx Chris ...
2
by: Mark | last post by:
I've built a class and overroad the Equals method. I've gotten the warning below. I'm unfamiliar with the "GetHashCode" method. An explantion of the method and its relation to the warning would...
2
by: Dot net work | last post by:
Hello, My simple code is here: Public Class MyDictionary Inherits System.Collections.DictionaryBase Private Class MyElement Public Overloads Overrides Function Equals(ByVal obj As Object)...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
5
by: taumuon | last post by:
I've got an object, Person, that supports IEquatable<Person>. It implements bool Equals(Person obj) as well as overriding bool Equals(object obj) I've got a container type that holds a member...
28
by: Tony Johansson | last post by:
Hello! I can't figure out what point it is to use GetHashCode. I know that this GetHashCode is used for obtaining a unique integer value. Can somebody give me an example that prove the...
0
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.