Public Interface ISomething
WriteOnly Property Prop As IParent
End Interface
そのインターフェース宣言は、クラスの実装では満たされていません。次の状況を考慮してください。
IChild2と呼ばれる別のインターフェイスがあります。
Public Interface IChild2
Inherits IParent
...
End Interface
インターフェイスによると、クラス実装のインスタンスは継承するため、にISomething
割り当てることができるはずです。ただし、プロパティは型であり、継承しないため、割り当てることはできません。IChild2
Thing.Prop
IParent
Thing.Prop
IChild
IChild2
IChild
アップデート
その解決策はどうですか?
Class ThingBase
Implements ISomething
Public WriteOnly Property Prop As IParent Implements ISomething.Prop
Set(value As IParent)
End Set
End Property
End Class
Class Thing
Inherits ThingBase
Public Overloads WriteOnly Property Prop As IChild
Set(value As IChild)
MyBase.Prop = value
End Set
End Property
End Class
Update2
Interface IView(Of T As IViewModel)
WriteOnly Property MyViewModel As T
End Interface
Class VerySpecialViewModel
Implements ISpecialViewModel
End Class
Class View
Implements IView(Of ISpecialViewModel)
Public WriteOnly Property MyViewModel As ISpecialViewModel Implements IView(Of ISpecialViewModel).MyViewModel
Set(value As ISpecialViewModel)
End Set
End Property
End Class
また
Class View
Implements IView(Of VerySpecialViewModel)
Public WriteOnly Property MyViewModel As VerySpecialViewModel Implements IView(Of VerySpecialViewModel).MyViewModel
Set(value As VerySpecialViewModel)
End Set
End Property
End Class