The types of positional and named parameters for an attribute class are limited to the attribute parameter types. A type is an attribute type if it is one of the following:
bool
, byte
, char
, double
, float
, int
, long
, short
, string
.object
.System.Type
.An attribute class that defines a positional or named parameter whose type is not an attribute parameter type is in error. The example
public class InvalidAttribute: System.Attribute { public InvalidAttribute(Class1 c) {…} // error } public class Class1 { ... }
is in error because it defines an attribute class with a positional parameter of type Class1
, which is not an attribute parameter type.