Prince

Prince

  • NA
  • 12
  • 0

Help:how to implement Icomparable uisng generics

Mar 17 2010 7:49 AM

this is a small portion from my code
public class Rational:IComparable<Rational>
{
// instance variables
private int numerator;
private int denominator;
.
.
.
// interface method with generics

public int CompareTo(Rational otherRational)
{
if (Rational < otherRational)
return -1;
else
if (Rational == otherRational)
return 0;
else
return 1;
}
i have this error message:Rational' is a 'type' but is used like a 'variable' 
i need help!

Answers (3)