类的属性是由派生类继承的,还是必须专门应用于派生类?
例如,system.timer.timer:
'Declaration
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True, _
ExternalThreading := True)> _
Public Class Timer _
Inherits Component _
Implements ISupportInitialize
如果我能上课
Class MyScheduler
Inherits Timer
'...
End Class
我是否需要将计时器calss的属性显式应用到MyScheduler类,或者这是继承的一部分?
默认情况下,属性不会被继承,但是您可以通过使用Inherited:=True
属性上的语法使它们可继承,如下所示:
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True, _
ExternalThreading := True, Inherited:=True)> _
Public Class Timer _
Inherits Component _
Implements ISupportInitialize
现在,任何派生自的类Timer
也将具有Timer
该类的属性,而子类属性将覆盖二者之间的所有冲突。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句