Raphael
Mon Feb 23 05:16:16 CST 2004
...thanks Alvin but your explanation falls short given the following
example:
DateTime date1 = new DateTime(2004, 02, 24);
DateTime date2 = new DateTime(2004, 02, 24);
Console.WriteLine(date1.Equals(date2));
DateTime is a value object and date1 and date2 were instantiated
exclusively, yet the outcome is always true.The same applies to integers,
booleans, etc; all value objects. Rather the problem I'd raised earlier on
is regarding Array objects specifically and we both know Array objects are
reference objects.
Regards, Raphael.
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:eVsmlTW%23DHA.4088@tk2msftngp13.phx.gbl...
> No the objects are not equal. Equals implements reference equality not
value
> equality. You are essentially asking whether or not object 1 and object 2
> live at the same address. They don't. They possibly live across the street
> from each other but not in the same house. What you are searching for is
> value equality. This method can be overridden by a derived class.
>
> --
> Regards,
> Alvin Bruney [ASP.NET MVP]
> Got tidbits? Get it here...
>
http://tinyurl.com/3he3b
> "Raphael Iloh" <ilohraphael@NOSPAMhotmail.com> wrote in message
> news:OeGEW7V%23DHA.3176@TK2MSFTNGP11.phx.gbl...
> > Hi all, I'm having problems comparing array objects. Take a look at
this:
> >
> > int[] array1 = new int[]{1};
> > int[] array2 = new int[]{1};
> > Console.Writeln(array1.Equals(array2));
> >
> > One would expect the above expression to return true as both arrays are
> > identically the same but it keeps returning false. Any info on how to
> solve
> > this problem will be appreciated.
> >
> >
> >
> > --
> > Regards,
> > Raphael Iloh (www.ilohraphael.net)
> > MCP, MCAD (C#)
> > This Posting is provided "AS IS", with no warranties and confers no
> rights.
> >
> >
>
>