我有一個基於示例代碼從MSDN微軟以下類:System.Collections.Generic收集和IEquatable錯誤
Imports System.Collections.Generic
Module SharedCode
Public Class Fund
Implements IEquatable(Of Fund)
'Class Fund must implement Function Equals(other As RetirementCalcOverTime.SharedCode.Fund) As Boolean for interface System.IEquatable(Of Fund)
Public Property FundName As String
Public Property StartDate As Date
Public Property StartBalance As Double
Public Property StartQuantity As Double
Public Property StartPrice As String
Public Sub New()
End Sub
Public Sub New(ByVal sFundName As String,
ByVal dStartDate As Date,
ByVal pStartBalance As Double,
ByVal pStartQuantity As Double,
ByVal pStartPrice As Double)
FundName = sFundName
StartDate = dStartDate
StartBalance = pStartBalance
StartQuantity = pStartQuantity
StartPrice = pStartPrice
End Sub
Public Function Overrides Equals(ByVal obj As Fund) As Boolean
'Overrides is flagged as invalid identifier
If obj Is Nothing Then
Return False
End If
Dim objAsFund As Fund = TryCast(obj, Fund)
If objAsFund Is Nothing Then
Return False
Else
Return Equals(objAsFund)
End If
End Function
End Class
End Module
我在做什麼錯,它覆蓋和的Equals函數拋出錯誤?
VS/VB將增加你需要的時候你在'Implements ...'行上按回車鍵 – Plutonix
這擺脫了執行錯誤,所以感謝那個Plutonix。 – twellsles