Inherited属性的bool属性指的是什么?
这是否意味着如果我使用属性定义了我的类AbcAtribute(具有Inherited = true),并且从该类继承了另一个类,则派生类也将具有相同的属性?
为了用一个代码示例来阐明这个问题,请想象以下内容:
[AttributeUsage(AttributeTargets.Class, Inherited = true)]
public class Random: Attribute
{ /* attribute logic here */ }
[Random]
class Mother
{ }
class Child : Mother
{ }
是否Child也Random应用了属性?
Inherited属性有一个精心制作的例子,显示之间的差异Inherited=true,并Inherited=false为双方继承的类和override方法。