Rather than by implementing an interface, this is accomplished through operator overloading. So, to overload the greater-than and less-than comparison operators, for instance, you could do something like this:
Public Class MyNumber
Public Value As Integer
Public Overloads Shared Operator >(ByVal x As MyNumber, ByVal y As MyNumber) As Boolean
Return (x.Value > y.Value)
End Operator
Public Overloads Shared Operator <(ByVal x As MyNumber, ByVal y As MyNumber) As Boolean
Return (x.Value < y.Value)
End Operator
End Class
Since operator overloads are defined as Shared
, they cannot be declared by an interface. Interfaces in VB.NET can only declare instance-members. They cannot declare shared members.