AttributeUsage : AttributeUsage : Attribute C# Examples


C# Examples » Attribute » AttributeUsage »

 

AttributeUsage





The 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  item)
    
   
  
   

item specifies the item or items upon which the attribute can be used.
AttributeTargets is an enumeration that defines the following values:

All
Assembly
Class
Constructor
Delegate
Enum
Event
Field
Interface
Method
Module
Parameter
Property
ReturnValue
Struct

Two or more of these values can be ORed together.




    
AttributeTargets.Field  |  AttributeTargets.Property
    
   
  
   


AttributeUsage supports two named parameters: AllowMultiple and Inherited.
AllowMultiple, a bool value. Whether the attribute can be applied more than one time to a single item.
Inherited, a bool value. Whether the attribute is inherited by derived classes.
The default setting for both AllowMultiple and Inherited is false.




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Attribute
» AttributeUsage