C# Programming - Attributes - Discussion

Discussion :: Attributes - General Questions (Q.No.2)

2. 

Which of the following are correct ways to specify the targets for a custom attribute?

[A]. By applying AttributeUsage to the custom attribute's class definition.
[B]. By applying UsageAttribute to the custom attribute's class definition.
[C]. Once an attribute is declared it applies to all the targets.
[D]. By applying AttributeUsageAttribute to the custom attribute's class definition.
[E]. None of the above.

Answer: Option D

Explanation:

No answer description available for this question.

K2U2007 said: (Sep 30, 2014)  
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)

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.