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
類型。
這兩種鑄件之間是否有任何性能差異?