#468 – Attributes Allow Adding Metadata to Program Elements

You can use an attribute to specify metadata that you want attached to some element in your application.  There are a number of predefined attributes in the .NET Framework, for various purposes.  You can also define your own custom attributes.

You can find a list of all predefined attributes here.

Here are a few examples of predefined attributes that you might use:

  • DebuggerDisplay – Tells Visual Studio how to display summary information about a type in a window that shows the current value of an object
  • Obsolete – Indicates that a method is obsolete and should no longer be used (issues a warning at compile time)
  • Serializable – Indicates that a type can be serialized (stored as a sequence of bytes).
  • WebMethod – Indicates that a method can be used through an XML web service