c# - Multiple AttributeTargets in AttributeUsage -
[attributeusage(attributetargets.property)] public class myattribute : attribute { ... } i want custom attribute used both on properties , fileds not others. how assign multiple targets(attributetargets.property , attributetargets.field)? or it's not possible?
and attributetargets.all not want.
you can specify multiple targets this, using | (bitwise or) operator specify multiple enum values:
[attributeusage(attributetargets.property | attributetargets.field)] public class myattribute : attribute { ... } the bitwise or operator works attributetargets enum because values assigned particular way , it's marked flags attribute.
if care to, can read more here:
Comments
Post a Comment