Summary

Attributes are a special type of metadata used to decorate program elements with information the programmer chooses. There are several pre-built attributes such as the Serializable and CLSCompliant attributes that you'll use on a regular basis.

When the pre-built attributes don't meet requirements, it's possible to create custom attributes. Custom attributes are special classes derived from the Attribute class and can be designed to support any metadata requirement imaginable.

The Attribute class has special methods for obtaining attribute metadata from program elements. Single attributes or all attributes associated with a program element may be extracted and read.

The metadata extraction capabilities described are merely a fraction ...

Get C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.