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

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -