Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Customer Class Implementing IComparable 1

Status
Not open for further replies.

andegre

MIS
Joined
Oct 20, 2005
Messages
275
Location
US
Hi, I'm having trouble implementing the IComparable interface with my custom class. Here's my code:

class ClassName : IComparable
{
public ClassName(){}
public int Compare(object obj1, object obj2)
{
return 1;
}
}

Obviously don't need to fill it with any more code, when trying to compile, it says "ClassName does not implement interface member 'System.IComparable.CompareTo(object)'

What am I missing here?

Thanks
 
the function name is CompareTo, not Compare.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Thanks Jason. That still didn't fix the compile issue though...
 
yep that wouldn't either. look at the signature of the interface. you want
Code:
class MyClass : ICompare
{
   public int CompareTo(object obj)
   {
      return 1;
   }
}

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Awesome, you saved the day again, Jason! Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top