.net - Inheritance of C# attribute classes -
how inheritance of attribute classes work in c#? clarify, talking inheritance of attribute classes (i.e. base classes of system.attributes
), not classes happen have them attribute.
for reason, cannot seem find on (my searches turn other meaning).
for example, if have class attributea
extends system.attribute
:
do have separately mark subclasses of
attributea
[attributeusage()]
. (sincesystem.attributeusage
's inheritancetrue
, don't think will.)will
allowmultiple=false
onattributeusage
ofattributea
prevent me having multiple subclasses ofattributea
attributes?
edit:
programmers can read code.
[attributeusage(attributetargets.class, allowmultiple=false)] class attributea { } class attributeb : attributea { } class attributec : attributea { } [attributeb] [attributec] class foo { }
does work?
you can control behavior using named parameter inherited attributeusageattribute.
[attributeusage(attributetargets.class, allowmultiple = false, inherited = false)] class attributea { } class attributeb : attributea { } class attributec : attributea { }
Comments
Post a Comment