C# Programming - Attributes - Discussion

Discussion Forum : Attributes - General Questions (Q.No. 2)
2.
Which of the following are correct ways to specify the targets for a custom attribute?
By applying AttributeUsage to the custom attribute's class definition.
By applying UsageAttribute to the custom attribute's class definition.
Once an attribute is declared it applies to all the targets.
By applying AttributeUsageAttribute to the custom attribute's class definition.
None of the above.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
2 comments Page 1 of 1.

K2u2007 said:   1 decade ago
AttributeUsage attribute specifies the types of items to which an attribute can be applied.

AttributeUsage is another name for the System.AttributeUsageAttribute class. AttributeUsage has the following constructor:

AttributeUsage(AttributeTargets validOn)

Hema said:   3 years ago
A is the right answer, as well as Attribute suffix, can be eliminated.

Post your comments here:

Your comments will be displayed after verification.