I creating a custom attribute and I would like to the set the AttributeUsage
(or maybe some other attribute in the attribute class) so that I my attribute can only be used in private methods, is that possible?
Thanks in advance for the answers!
I creating a custom attribute and I would like to the set the AttributeUsage
(or maybe some other attribute in the attribute class) so that I my attribute can only be used in private methods, is that possible?
Thanks in advance for the answers!
Copyright © 2021 Jogjafile Inc.
There is no such feature available in
C# (as of 4.0)
that allows you to restrictattribute
usage based on a member's accessibility.The question would be why do you want to do that?
Because given below attribute,
and below class,
You can easily get attributes of private methods using following code: