Attributes

Metadata or declarative information on types, methods, and properties can be associated using attributes. Metadata refers to what types are defined in a program. For instance, a class is a type: each class defines certain properties and methods, each property is of a type, and each method accepts certain data types and returns certain data types. All this information is referred to as metadata and can be accessed and retrieved during program execution.

Like any other method, while you define an attribute, you can define the parameters as well. You can define one or more attributes on an assembly, class, method, or property. Based on the program requirements, you can define what types of attribute your application needs and define them in your program. Once defined, you can read this information while executing your program and then process it.

In the following section, we will demonstrate how to use attributes and create custom attributes as per our requirements.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.25.217