[AttributeUsage(AttributeTargets.All)] |
All attributes derive directly or indirectly from class Attribute. Attributes can be applied to any target element (see AttributeTargets); multiple instances of an attribute can be applied to the same target element; and attributes can be inherited by an element derived from a target element. Compilers and other development tools use this information to identify which attributes are custom attributes.
Custom attributes can be stored with any element of the metadata. This mechanism can be used to store application-specific information at compile time and access it either at runtime or when another tool reads the metadata.
.NET Framework predefines some attribute types and uses them to control runtime behavior. Some languages predefine attribute types to represent language features not directly represented in the .NET Framework common type system. Users or other tools are welcome to define and use additional attribute types.
For more information about using attributes, see the conceptual topic at MSDN: extendingmetadatausingattributes.
TypeId | Read-only When implemented in a derived class, gets a unique identifier for this Attribute. |
Equals | Overridden: Returns a value indicating whether this instance is equal to a specified object. |
GetCustomAttribute | Overloaded:GetCustomAttribute(Assembly element, Type attributeType) Retrieves a custom attribute of a specified type applied to a specified assembly or inherited from a base class. |
GetCustomAttribute | Overloaded:GetCustomAttribute(MemberInfo element, Type attributeType) Retrieves a custom attribute of a specified type applied to a specified member of a class or inherited from a base class. |
GetCustomAttribute | Overloaded:GetCustomAttribute(Module element, Type attributeType) Retrieves a custom attribute of a specified type applied to a specified module or inherited from a base class. |
GetCustomAttribute | Overloaded:GetCustomAttribute(ParameterInfo element, Type attributeType) Retrieves a custom attribute of a specified type applied to a specified parameter of a member of a class or inherited from a base class. |
GetCustomAttribute | Overloaded:GetCustomAttribute(Assembly element, Type attributeType, bool inherit) Retrieves a custom attribute of a specified type applied to a specified assembly or optionally inherited from a base class. |
GetCustomAttribute | Overloaded:GetCustomAttribute(MemberInfo element, Type attributeType, bool inherit) Retrieves a custom attribute of a specified type applied to a specified member of a class or optionally inherited from a base class. |
GetCustomAttribute | Overloaded:GetCustomAttribute(Module element, Type attributeType, bool inherit) Retrieves a custom attribute of a specified type applied to a specified module or optionally inherited from a base class. |
GetCustomAttribute | Overloaded:GetCustomAttribute(ParameterInfo element, Type attributeType, bool inherit) Retrieves a custom attribute of a specified type applied to a specified parameter of a member of a class or optionally inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(Assembly element) Retrieves an array of the custom attributes of a specified type applied to a specified assembly or inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(MemberInfo element) Retrieves an array of the custom attributes applied to a specified member of a class or inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(Module element) Retrieves an array of the custom attributes of a specified type applied to a specified module or inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(ParameterInfo element) Retrieves an array of the custom attributes of a specified type applied to a specified parameter of a member of a class or inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(Assembly element, bool inherit) Retrieves an array of the custom attributes of a specified type applied to a specified assembly or optionally inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(Assembly element, Type attributeType) Retrieves an array of the custom attributes of a specified type applied to a specified assembly or inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(MemberInfo element, bool inherit) Retrieves an array of the custom attributes of a specified member of a class or inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(MemberInfo element, Type type) Retrieves an array of the custom attributes of a specified type applied to a specified member of a class or inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(Module element, bool inherit) Retrieves an array of the custom attributes of a specified type applied to a specified module or optionally inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(Module element, Type attributeType) Retrieves an array of the custom attributes of a specified type applied to a specified module or inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(ParameterInfo element, bool inherit) Retrieves an array of the custom attributes of a specified type applied to a specified parameter of a member of a class or optionally inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(ParameterInfo element, Type attributeType) Retrieves an array of the custom attributes of a specified type applied to a specified parameter of a member of a class or inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(Assembly element, Type attributeType, bool inherit) Retrieves an array of the custom attributes of a specified type applied to a specified assembly or optionally inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(MemberInfo element, Type type, bool inherit) Retrieves an array of the custom attributes of a specified type applied to a specified member of a class or optionally inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(Module element, Type attributeType, bool inherit) Retrieves an array of the custom attributes of a specified type applied to a specified module or optionally inherited from a base class. |
GetCustomAttributes | Overloaded:GetCustomAttributes(ParameterInfo element, Type attributeType, bool inherit) Retrieves an array of the custom attributes of a specified type applied to a specified parameter of a member of a class or optionally inherited from a base class. |
GetHashCode | Overridden: Returns the hash code for this instance. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
IsDefaultAttribute | When overridden in a derived class, returns an indication whether the value of this instance is the default value for the derived class. |
IsDefined | Overloaded:IsDefined(Assembly element, Type attributeType) Determines whether any custom attributes of a specified type are applied to a specified assembly. |
IsDefined | Overloaded:IsDefined(MemberInfo element, Type attributeType) Determines whether any custom attributes of a specified type are applied to a specified member of a class or inherited from a base class. |
IsDefined | Overloaded:IsDefined(Module element, Type attributeType) Determines whether any custom attributes of a specified type are applied to a specified module. |
IsDefined | Overloaded:IsDefined(ParameterInfo element, Type attributeType) Determines whether any custom attributes of a specified type are applied to a specified parameter of a member of a class or inherited from a base class. |
IsDefined | Overloaded:IsDefined(Assembly element, Type attributeType, bool inherit) Determines whether any custom attributes of a specified type are applied to a specified assembly. |
IsDefined | Overloaded:IsDefined(MemberInfo element, Type attributeType, bool inherit) Determines whether any custom attributes of a specified type are applied to a specified member of a class or optionally inherited from a base class. |
IsDefined | Overloaded:IsDefined(Module element, Type attributeType, bool inherit) Determines whether any custom attributes of a specified type are applied to a specified module. |
IsDefined | Overloaded:IsDefined(ParameterInfo element, Type attributeType, bool inherit) Determines whether any custom attributes of a specified type are applied to a specified parameter of a member of a class or optionally inherited from a base class. |
Match | When overridden in a derived class, returns a value indicating whether this instance equals a specified object. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
ctor #1 | Default constructor. This constructor is called by derived class constructors to initialize state in this type. Initializes a new instance of the Attribute class. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
protected Attribute(); |
public virtual object TypeId {get;}
|
obj
~Attribute(); |
element
attributeType
-or-
An Attribute reference to the single custom attribute of type attributeType that is applied to element.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
AmbiguousMatchException | More than one of the requested attributes was found. |
public static Attribute GetCustomAttribute( |
element
attributeType
-or-
An Attribute reference to the single custom attribute of type attributeType that is applied to element.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
NotSupportedException | element is not a constructor, method, property, event, type, or field. |
AmbiguousMatchException | More than one of the requested attributes was found. |
element
attributeType
-or-
An Attribute reference to the single custom attribute of type attributeType that is applied to element.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
AmbiguousMatchException | More than one of the requested attributes was found. |
public static Attribute GetCustomAttribute( |
element
attributeType
-or-
An Attribute reference to the single custom attribute of type attributeType that is applied to element.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
AmbiguousMatchException | More than one of the requested attributes was found. |
public static Attribute GetCustomAttribute( |
element
attributeType
inherit
-or-
An Attribute reference to the single custom attribute of type attributeType that is applied to element.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
AmbiguousMatchException | More than one of the requested attributes was found. |
public static Attribute GetCustomAttribute( |
element
attributeType
inherit
-or-
An Attribute reference to the single custom attribute of type attributeType that is applied to element.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
NotSupportedException | element is not a constructor, method, property, event, type, or field. |
AmbiguousMatchException | More than one of the requested attributes was found. |
public static Attribute GetCustomAttribute( |
element
attributeType
inherit
-or-
An Attribute reference to the single custom attribute of type attributeType that is applied to element.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
AmbiguousMatchException | More than one of the requested attributes was found. |
public static Attribute GetCustomAttribute( |
element
attributeType
inherit
-or-
An Attribute reference to the single custom attribute of type attributeType that is applied to element.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
AmbiguousMatchException | More than one of the requested attributes was found. |
public static Attribute[] GetCustomAttributes( |
element
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
public static Attribute[] GetCustomAttributes( |
element
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element is null. |
NotSupportedException | element is not a constructor, method, property, event, type, or field. |
public static Attribute[] GetCustomAttributes( |
element
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element is null. |
public static Attribute[] GetCustomAttributes( |
element
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element is null. |
public static Attribute[] GetCustomAttributes( |
element
inherit
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
public static Attribute[] GetCustomAttributes( |
element
attributeType
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
public static Attribute[] GetCustomAttributes( |
element
inherit
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element is null. |
NotSupportedException | element is not a constructor, method, property, event, type, or field. |
public static Attribute[] GetCustomAttributes( |
element
type
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element or type is null. |
ArgumentException | type is not derived from Attribute. |
NotSupportedException | element is not a constructor, method, property, event, type, or field. |
public static Attribute[] GetCustomAttributes( |
element
inherit
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
public static Attribute[] GetCustomAttributes( |
element
attributeType
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
public static Attribute[] GetCustomAttributes( |
element
inherit
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element is null. |
public static Attribute[] GetCustomAttributes( |
element
attributeType
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
public static Attribute[] GetCustomAttributes( |
element
attributeType
inherit
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
public static Attribute[] GetCustomAttributes( |
element
type
inherit
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element or type is null. |
ArgumentException | type is not derived from Attribute. |
NotSupportedException | element is not a constructor, method, property, event, type, or field. |
public static Attribute[] GetCustomAttributes( |
element
attributeType
inherit
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
public static Attribute[] GetCustomAttributes( |
element
attributeType
inherit
-or-
An empty array if no such custom attributes exist.
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
public override int GetHashCode(); |
public Type GetType(); |
public virtual bool IsDefaultAttribute(); |
The implementation of this method in a derived class compares the value of this instance to a standard, default value obtained by some means, then returns a Boolean value that indicates whether the value of this instance is equal to the standard. The standard value is typically coded as a constant in the implementation, or stored programmatically in a field used by the implementation.
element
attributeType
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
public static bool IsDefined( |
element
attributeType
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
NotSupportedException | element is not a constructor, method, property, event, type, or field. |
element
attributeType
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
public static bool IsDefined( |
element
attributeType
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
element
attributeType
inherit
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
public static bool IsDefined( |
element
attributeType
inherit
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
NotSupportedException | element is not a constructor, method, property, event, type, or field. |
element
attributeType
inherit
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
public static bool IsDefined( |
element
attributeType
inherit
Exception Type | Condition |
---|---|
ArgumentNullException | element or attributeType is null. |
ArgumentException | attributeType is not derived from Attribute. |
ExecutionEngineException | element is not a method, constructor, or type. |
obj
protected object MemberwiseClone(); |
public virtual string ToString(); |