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!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no such feature available in
C# (as of 4.0)that allows you to restrictattributeusage 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: