我可以覆盖接口属性吗?

Cur*_*tis 2 vb.net implementation overriding properties interface

Shell示例如下.基本上,我希望客户和员工从IPerson实施SSN属性.但是,我希望客户得到并设置(这不是问题),但我希望员工只得到.

Public Interface IPerson
    Property SSN As String
End Interface

Public Class Client
    Implements IPerson
    Public Property SSN As String Implements AELName.IPerson.SSN
        Get
            Return _SSN
        End Get
        Set(value As String)
            _SSN = value
        End Set
    End Property
End Class

Public Class Employee
    Implements IPerson
    Public Readonly Property SSN As String Implements AELName.IPerson.SSN
        Get
            Return _SSN
        End Get
    End Property
End Class
Run Code Online (Sandbox Code Playgroud)

员工生成错误"'SSN'无法实现'SSN',因为接口'IPerson'上没有匹配的属性".是否有一种简单的方法来覆盖Employee的SSN实现?

Ode*_*ded 5

您可以实现一个空的Set- 不更新任何内容的空.

Public Class Employee
    Implements IPerson
    Public Readonly Property SSN As String Implements AELName.IPerson.SSN
        Get
            Return _SSN
        End Get
        Set
            ' Make read only for Employee
        End Set
    End Property
End Class
Run Code Online (Sandbox Code Playgroud)