Attributes

  • Attributes, which are saved with an assembly's metadata, annotate programming elements such as types, fields, methods, and properties
  • . NET defines a number of standard attributes that can be used to provide functionality, such as serialization, security, and compilation modifications etc.,
  • Attributes are generally applied physically in front of type and type member declarations.
  • They're declared with square brackets, "[" and "] ".

    E.g.:     [ObsoleteAttribute]

    E.g.:    [Serializable]

        public class myClass{.......}

  • Attributes often have parameters that enable customization. 

    E.g.:     [Obsolete("You shouldn't use this method anymore.")]

  • Attribute targets are specified by prefixing the attribute name with the target and separating it with a colon (:). 
  • Custom attributes are defined in attribute classes based on the System.Attribute class. Custom attributes provide additional metadata that can be embedded in your class and examined at run time.

0 comments :

Post a Comment

> Related Posts with Thumbnails
 

Copyright © 2012. GS dot net - All Rights Reserved - Design by BTDesigner - Proudly powered by Blogger