Chapter 18. Custom Attributes

In this chapter:

Using Custom Attributes

Defining Your Own Attribute Class

Attribute Constructor and Field/Property Data Types

Detecting the Use of a Custom Attribute

Matching Two Attribute Instances Against Each Other

Detecting the Use of a Custom Attribute Without Creating Attribute-Derived Objects

Conditional Attribute Classes

In this chapter, I’ll discuss one of the most innovative features the Microsoft .NET Framework has to offer: custom attributes. Custom attributes allow you to declaratively annotate your code constructs, thereby enabling special features. Custom attributes allow information to be defined and applied to almost any metadata table entry. This extensible metadata information can be queried at run time ...

Get CLR via C#, Fourth Edition 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.