George George

George George

  • NA
  • 778
  • 0

default comparer

Jun 13 2008 4:55 AM

Hello everyone,


For a customized class, like I showed in my sample, what will Comparer<>.Default be returned? In my sample, there is System.ArgumentException.

[Code]
class Program
    {
        class Foo
        {

        }
       
        static void Main(string[] args)
        {
            IComparer<Foo> FooComparer = Comparer<Foo>.Default;
            Foo f1 = new Foo();
            Foo f2 = new Foo();

            // System.ArgumentException
            FooComparer.Compare(f1, f2);

            return;
        }
    }
[/Code]


thanks in advance,
George


Answers (2)