Chapter 17. Attributes

You have seen how modifiers like public and abstract can be applied to classes, interfaces, and other types to change how they behave. The .NET attribute feature allows you to create and apply your own modifiers without having to add keywords to the C# language.

In this chapter, I'll show you two of the many dozens of attributes that are included in the .NET Framework Class Library, how to test for the presence of an attribute, and how to create and apply custom attributes. Table 17-1 provides the summary for this chapter.

Table 17-1. Quick Problem/Solution Reference for Chapter 17




Modify the behavior of a C# code element.

Apply an attribute.

17-1, 17-2

Test to see whether an attribute has been applied to ...

Get Introducing Visual C# 2010 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.