O'Reilly logo

C# Primer: A Practical Approach by Stanley B. Lippman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8.6. Attributes

Attributes serve as metadeclarative information. C# supports several predefined (sometimes called intrinsic) attributes. In addition, the programmer can define new attribute types. These can be retrieved and queried at runtime through type reflection. Both the intrinsic and user-defined attributes are classes, although their syntax appears text based. Before we look at how we can define our own attribute types, let's briefly review the intrinsic attributes.

8.6.1. The Intrinsic Conditional Attribute

The Conditional attribute enables us to define class methods that are conditionally invoked on the basis of whether an associated string is defined. (We cannot, however, place a Conditional attribute on data members or properties.) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required