Thread: default comparer

  1. #1
    Registered User
    Join Date
    May 2006

    default comparer

    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.

    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);

    thanks in advance,

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    Too lazy for reading again ? Read the text of the exception. Read the MSDN for Comparer, especially the first block that is named "Remarks". Then it should be obvious, what you are missing.

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Utilizing another compiled program for a task.
    By kotoroshinoto in forum C Programming
    Replies: 6
    Last Post: 06-03-2008, 01:43 PM
  2. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  3. constructors
    By shrivk in forum C++ Programming
    Replies: 7
    Last Post: 06-24-2005, 09:35 PM
  4. A question about constructors...
    By Wolve in forum C++ Programming
    Replies: 9
    Last Post: 05-04-2005, 04:24 PM
  5. Switching Default Buttons :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 07-02-2002, 04:08 PM