0
考虑这个examlpe它是否可以提高性能并降低级别类型?
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
类型。
这两种铸件之间是否有任何性能差异?