December 2001
Intermediate to advanced
416 pages
8h 16m
English
An attribute is actually an instance of a class. We can introduce our own attributes, provided that the class representing an attribute inherits either directly or indirectly from the System.Attribute class. In addition, for nonabstract classes there must be at least one public constructor, and the class must have public accessibility. Here is a simple attribute class suggested from the Microsoft documentation. It defines an Author attribute that allows the programmer to tag her code with metadata attributes such as the implementor's name, the code version, and comment:
[AttributeUsage( AttributeTargets.ClassMembers, AllowMultiple = true )] public class AuthorAttribute: Attribute { public AuthorAttribute( ...Read now
Unlock full access