Attributes in themselves don't do anything unless a program or the runtime looks for them. When you ask a certain type for its custom attributes, the runtime creates an instance of the attribute class and invokes one of the class's constructors. The runtime looks at the arguments of the attribute to determine which constructor to invoke. The runtime then sets the value of any of the named fields. For the following example, assume that we're looking for custom attributes of type VisibleColumn and that these attributes can only be applied to a class's fields. To search for custom attributes:
Tips
|