[Mono-list] Mono/.Net: object comparison

Julien Sobrier julien at sobrier.net
Thu Jun 30 18:16:16 EDT 2005


Martin Hinks a écrit :
> Sounds like a classic referencing problem, I would think logically
> that myArray[0] different from foo is the correct behaviour...
> 
> MyClass test = new MyClass ("1","2","3");
> MyClass test2 = new MyClass ("1","2","3");
> 
> test != test2
> 
> They have different references although the values are the same...
> 
> I wouldn't therefore be able to do test.String1 = "new" and expect the
> value of test2.String1 to change. They are different objects...
> 
> So, the answer is that Mono seems to be comparing on memory reference
> whilst .NET does the comparison on value. Guess a bugzilla report is
> needed, I can file it if you want or you can as you have the working
> test case...

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


More information about the Mono-list mailing list