如何覆盖可继承的属性?
E.g。 (使用样本的MSDN名称):
[AttributeUsage(AttributeTargets.Property, Inherited = true)]
class Attr1 : Attribute { ... }
class BClass
{
[Attr1( x )]
int i;
}
class DClass1 : BClass
{
// Will use Attr1(x) by inheritance and that's ok.
override int i;
}
class DClass2 : BClass
{
// This will not work, will use Attr1(x) instead of Attr1(y) - NOK!
[Attr1( y )]
override int i;
}
谢谢!
编辑:似乎问题似乎与C# Override an attribute in a subclass相同,但使用新代替覆盖似乎无法解决我的问题。此外,该问题会发出删除属性,而我的问题则解决现有属性的覆盖。也许它在某种程度上有所不同。