Jump to content
Xtreme .Net Talk

IComparer use


Recommended Posts

Guest Krassimir Manev
Posted

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...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...