#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
Advertisements

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

2 Responses to #468 – Attributes Allow Adding Metadata to Program Elements

  1. Pingback: #469 – Attaching an Attribute to a Type Member « 2,000 Things You Should Know About C#

  2. Peter Chamberlin says:

    Typo: “an attribute specify” → ‘an attribute to specify’

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: