By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,566 Members | 1,719 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,566 IT Pros & Developers. It's quick & easy.

IComparable Question

P: n/a
In the first class below, I get an error that
AnotherClientBaseDataRecord does not implement
IComparable.CompareTo(object)...yet the second class below is
implemented identicially and it does get the compile error. I'd love
help understanding this :=) ....

Why does this not compile
public class AnotherClientBaseDataRecord : IComparable
{
public AnotherClientBaseDataRecord() {}
public int CompareTo(AnotherClientBaseDataRecord otherRecord) {
return 0;}
}

public class BuildFileRecord : IComparable
{
public BuildFileRecord () {}
public int CompareTo(BuildFileRecord otherRecord) { return 0;}
}
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"raffelm" <ma*********@mindspring.com> wrote in message
news:ba**************************@posting.google.c om...
In the first class below, I get an error that
AnotherClientBaseDataRecord does not implement
IComparable.CompareTo(object)...yet the second class below is
implemented identicially and it does get the compile error. I'd love
help understanding this :=) ....

Why does this not compile
public class AnotherClientBaseDataRecord : IComparable
{
public AnotherClientBaseDataRecord() {}
public int CompareTo(AnotherClientBaseDataRecord otherRecord) {
return 0;}
}

public class BuildFileRecord : IComparable
{
public BuildFileRecord () {}
public int CompareTo(BuildFileRecord otherRecord) { return 0;}
}


Hi raffelm,

You need to make the signature of the CompareTo method match what is defined
in IComparable:

public class AnotherClientBaseDataRecord : IComparable
{
public AnotherClientBaseDataRecord() {}
public int CompareTo(object otherRecord)
{
return 0;}
}

public class BuildFileRecord : IComparable
{
public BuildFileRecord () {}
public int CompareTo(object otherRecord) { return 0;}
}

BTW, you should have received compile errors for both classes. To prove
that you will receive an error for BuildFileRecord, fix
AnotherClientBaseRecord first and recompile.

Joe
--
http://www.csharp-station.com
Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.