VB.NET class inherits a base class and implements an interface issue (works in C#)

后端 未结 7 1682
后悔当初
后悔当初 2020-12-09 14:53

I am trying to create a class in VB.NET which inherits a base abstract class and also implements an interface. The interface declares a string property called Description. T

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 15:39

    I can't comment on M.A. Hanin's answer because of my rep, but I would recommend one small tweak to avoid compiler warnings about hiding base methods, assuming you don't want to or can't override override the property in the base class.

    Public Class MyFoo
        Inherits FooBase
        Implements IFoo
        Private Property IFoo_Description() As String Implements IFoo.Description
            Get
                Return Me.Description
            End Get
            Set(ByVal value As String)
                Me.Description = value
            End Set
        End Property
    End Class
    

提交回复
热议问题