十分简单
- VB code
'[code=VB]
Public Class ProductInfo
Implements IComparable'这里这句话是做什么用的
Public _productName As String
Public _productPrice As Decimal
Public Sub New(ByVal name As String, ByVal price As Decimal)
_productName = name
_productPrice = price
End Sub
Public Function CompareTo(ByVal obj As Object) As Integer _
Implements IComparable.CompareTo'还有这里,能否解释哈哈
Dim p As ProductInfo = CType(obj, ProductInfo)
'产品价格的比较
If (p._productPrice > _productPrice) Then Return -1
If (p._productPrice < _productPrice) Then Return 1
Return 0
End Function
End Class
[/code]
[解决办法]
Public Class ProductInfo
Implements IComparable'这里这句话是做什么用的 实现IComparable这个接口
Public _productName As String
Public _productPrice As Decimal
Public Sub New(ByVal name As String, ByVal price As Decimal)
_productName = name
_productPrice = price
End Sub
Public Function CompareTo(ByVal obj As Object) As Integer _
Implements IComparable.CompareTo'还有这里,能否解释哈哈实现IComparable'这个接口里面的CompareTo'方法
Dim p As ProductInfo = CType(obj, ProductInfo)
'产品价格的比较
If (p._productPrice > _productPrice) Then Return -1
If (p._productPrice < _productPrice) Then Return 1
Return 0
End Function
End Class