[Mono-list] Different behaviour of Mono to .NET regarding BinarySearch

Sam Jost monolist@radeldudel.de
Fri, 23 Jul 2004 09:23:23 +0200


Hi!

I really don't think this one is important, but I found a difference between
Mono and .NET 1.1.

Both ways are correct, that's why I think it's unimportant, it might just be
interesting to note in case someone is relying on this undocumented
behaviour of .net:

I hope the test case here is good enough to understand the difference for
anyone interested:

Sam


---- testcase starts
using NUnit.Framework;
using System;
using System.Collections;
using System.Diagnostics;

namespace SamsTests
{
 [TestFixture]
 public class BinarySearchComparerTest
 {

  private class BinSearchComparer:IComparer
  {
   public int Compare( object  x, object  y)
   {
    if (x.GetType()==typeof(String))
     Trace.WriteLine( "you are using MONO");
    if (y.GetType()==typeof(String))
     Trace.WriteLine( "you are using .NET");
    return 0;
   }
  }

  [Test] public void Testit()
  {
   ArrayList l= new ArrayList();
   l.Add( 10.0m);
   l.BinarySearch( "t", new BinSearchComparer());
  }
 }
}
---- testcase ends