考虑一下这个例子
Interface IInterface
Property MyProperty
End Interface
Class MyClassy : Implements IInterface
Public Property MyProperty
End Class
Class MyClassy2 : Inherits MyClassy
End MyClassy
Class MyClassy3 : Inherits MyClassy
End MyClassy
Class MyClassy4 : Inherits MyClassy
End MyClassy
Class MyClassy5 : Inherits MyClassy
End MyClassy
Private Sub MyHandler(sender As Object, e As EventArgs)
'Here is my question:
Dim lowLevel = DirectCast(sender, IInterface).MyProperty
'vs.
Dim highLevel = DirectCast(sender, MyClassy5).MyProperty
End Sub
类型
sender
在上面的例子中是
MyClassy5
.
这两种铸件的性能有什么不同吗?