473,402 Members | 2,064 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,402 software developers and data experts.

Array Equality

Hello, all!

There's no documentation of an overriden Equals() method for arrays, and
there does not seem to be one in fact, since any of these assertions will
crash:
int[] x = { 0, 1 };
int[] y = { 0, 1 };

// System.Diagnostics.Debug.Assert(x == y, "Arrays equal?");
// System.Diagnostics.Debug.Assert(Array.Equals(x, y), "Arrays equal?");
// System.Diagnostics.Debug.Assert(x.Equals(y), "Arrays equal?");

Obviously I can loop through them, but do I have to?

Tony Nassar
The Analysis Corp.
703-208-9630


Nov 15 '05 #1
3 6718
Tony Nassar <tn*****@theanalysiscorp.com> wrote:
There's no documentation of an overriden Equals() method for arrays, and
there does not seem to be one in fact, since any of these assertions will
crash:
int[] x = { 0, 1 };
int[] y = { 0, 1 };

// System.Diagnostics.Debug.Assert(x == y, "Arrays equal?");
// System.Diagnostics.Debug.Assert(Array.Equals(x, y), "Arrays equal?");
// System.Diagnostics.Debug.Assert(x.Equals(y), "Arrays equal?");

Obviously I can loop through them, but do I have to?


Yes, I believe you do.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
Oh, I know I do; don't worry about that. But I must say, it's peculiar that
the '==' operator returns 'false' in this case! A "not implemented
exception" I could understand, but 'false'?
Nov 15 '05 #3
Tony Nassar <tn*****@theanalysiscorp.com> wrote:
Oh, I know I do; don't worry about that. But I must say, it's peculiar that
the '==' operator returns 'false' in this case! A "not implemented
exception" I could understand, but 'false'?


Why would it *not* return false? It's just using object==, which
compares two references.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #4

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

Similar topics

12
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are...
7
by: simondex | last post by:
Hi, Everyone! How could I make sure that nine values (from 0 to N) are all different without writing too many loops? I am not afraid of statistical parameters (e.g. coefficient of variation,...
40
by: Ike Naar | last post by:
In K&R "The C++ programming language (2nd ANSI C edition), the reference manual states (paragraphs 7.9 and 7.10) that pointer comparison is undefined for pointers that do not point to the same...
32
by: Carson | last post by:
Hi , Is there a very efficient way to set a double array to 0 ? (I have tried memset, but the result doesn't look correct.) Carson
11
by: gouqizi.lvcha | last post by:
Hi all I have a large vector with float point numbers in it, for example (1.1, 2.1 , 3.2 , 3.3 , 4, 6, 3.2, 8). Is there an easy way to determine how many uique elements in the array? Thanks...
8
by: Kenneth Baltrinic | last post by:
I am trying to compare values coming out of a database record with known default values. The defaults are in an array of type object (because they can be of any basic data type, I am not working...
37
by: spam.noam | last post by:
Hello, Guido has decided, in python-dev, that in Py3K the id-based order comparisons will be dropped. This means that, for example, "{} < " will raise a TypeError instead of the current...
12
by: John Smith | last post by:
This code for the comparison of fp types is taken from the C FAQ. Any problems using it in a macro? /* compare 2 doubles for equality */ #define DBL_ISEQUAL(a,b)...
1
by: mlarsen1982 | last post by:
Hello everyone I am trying to write this application that picks a random number between 1-1000, and prompts the user to attempt to enter a number to try to guess it. Depending on how far or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
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...

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.