Reply to thread

I'v created IComparer for SortedList collection but compiler do not like how I'm using it:


class IntReverse : IComparer

{   public int Compare(object x, object y)

    {  int xcopy = (int)x, ycopy = (int)y;

            if (xcopy > ycopy) return -1; else return 1;

      }

 }

  class Program

 {  static void Main()

     {  IComparer comp = new IntReverse();

         SortedList<int,string> a = new SortedList<int, string>(comp);

      }

 }


 Error message:

Error    CS1503    Argument 1: cannot convert from 'System.Collections.IComparer' to 'int'


Continue reading...


Back
Top