Hello Julien,
I'm sorry but I could not reproduce this behaviour with .NET 1.1. Am I doing
anyhing wrong?
Here is the source code:
===
using System.Collections;
public class A
{
public string a = "a";
public string b = "b";
public string c = "c";
}
public class Program
{
public static void Main()
{
ArrayList list = new ArrayList();
list.Add(new A());
A a = new A();
if (list.Contains(a))
System.Console.WriteLine("bad");
else
System.Console.WriteLine("good");
}
}
===
It outputs "good" for me on .NET 1.1, compiled with csc, which I suppose to be
the correct behaviour.
I have been confused a lot when you mentioned that new A() == new A() or
ArrayList.Contains(new A()) may return true for a clean class A
(without overridden Equals(), GetHashCode(), operator == etc).
Do you have Equals(), GetHashCode() or operator == () overridden?
With best regards,
Dmitry Kostenko
> ------------------------------
>
> Message: 3
> Date: Thu, 30 Jun 2005 18:16:16 -0400
> From: Julien Sobrier <[EMAIL PROTECTED]>
> Subject: Re: [Mono-list] Mono/.Net: object comparison
> To: [email protected]
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Sorry for the delay. I did some tests with 1.1.8, same problem.
>
> The code looks like this:
>
> ArrayList list = new ArrayList();
>
> list.Add(new MyClass());
>
> MyClass one = new MyClass();
>
> bool result = list.Contains(one); --> return false with mono, true with
> dot-net
>
> I'll add this to bugzilla next week.
>
> Thank you
>
_______________________________________________
Mono-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list