gfrizzle
gfrizzle

Reputation: 12619

Can't see "Must implement" error

I need another (dozen) pair of eyes on this. The following code:

Interface iRuleEntity
    Function GetRuleViolations() As List(Of RuleViolation)
End Interface

Partial Public Class Feedback
    Implements iRuleEntity

    Public Function GetRuleViolations() As List(Of RuleViolation)
        Return Nothing
    End Function

End Class

is giving me this error:

'Feedback' must implement 'Function GetRuleViolations() As System.Collections.Generic.List(Of RuleViolation)' for interface 'iRuleEntity'.

What am I missing?

Upvotes: 2

Views: 1709

Answers (2)

RossFabricant
RossFabricant

Reputation: 12502

Partial Public Class Feedback
    Implements iRuleEntity

    Public Function GetRuleViolations() As List(Of RuleViolation)
        Implements iRuleEntity.GetRuleViolations

        Return Nothing
    End Function

End Class

Upvotes: 3

Jon Skeet
Jon Skeet

Reputation: 1504052

You haven't said that GetRuleViolations implements iRuleEntity.GetRuleViolations. It's not implicit like it is in C#.

From the docs for Implements:

You use the Implements statement to specify that a class or structure implements one or more interfaces, and then for each member you use the Implements keyword to specify which interface and which member it implements.

So:

Partial Public Class Feedback
    Implements iRuleEntity

    Public Function GetRuleViolations() As List(Of RuleViolation) _
    Implements iRuleEntity.GetRuleViolations
        Return Nothing
    End Function

End Class

(Note the line continuation on the first line of the function.)

Upvotes: 10

Related Questions