Valid Attribute Parameter Types
The types of positional parameters and named parameters for an attribute class are limited to the attribute parameter types, which are listed here: -
- bool, byte, char, double, float, int, long, short, string
- System. Type
- · object
- An enum type, provided that it and any types in which it is nested are publicly accessible-as in the example used with the RegistryHives enumeration
- A one-dimensional array involving any of the types listed above
Because the parameter types are limited to the types in this list, you can't pass data structures like classes to the attribute constructor. This restriction makes sense because attributes are attached at design time and you wouldn't have the instantiated instance of the class (an object) at that point. With the valid types listed above, you can hard-code their values at design time, which is why they can be used.