Use Attributes to mark a method : Attribute : Attribute C# Examples


C# Examples » Attribute » Attribute »

 

Use Attributes to mark a method





You can add declarative information to a program by using an attribute.
An attribute defines additional information that is associated with a class, structure, method, and so on.

An attribute is supported by a class that inherits System.Attribute.
All attribute classes must be subclasses of System.Attribute.
This built-in attribute AttributeUsage specifies the types of items to which the attribute can be applied.





    
using  System.Diagnostics;


class  MainClass
{
        [Conditional("DEBUG")]
        public  void  Validate()
        {
        }
}
    
   
  
   

C# defines three built-in attributes:

AttributeUsage,
Conditional,
Obsolete.




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Attribute
» Attribute