[AttributeUsage(AttributeTargets.Class)] |
Attribute classes have positional and named parameters. Each public constructor for an attribute class defines a valid sequence of positional parameters for that class. Named parameters are defined by the non-static, public, and read-write fields or properties of the attribute class.
The three properties of AttributeUsageAttribute are set by defining the following parameters:
This positional parameter specifies the program elements that the indicated attribute can be placed on. The set of all possible elements that you can place an attribute on is listed in the AttributeTargets enumerator. You can combine several AttributeTargets values using a bitwise OR operation to get the desired combination of valid program elements.This named parameter specifies whether the indicated attribute can be specified more than once for a given program element.
This named parameter specifies whether the indicated attribute can be inherited by derived classes and overridden members.
For more information about using attributes, see Attribute and the conceptual topic at MSDN: extendingmetadatausingattributes.
ctor #1 | Initializes a new instance of the AttributeUsageAttribute class with the specified list of AttributeTargets, the AttributeUsageAttribute.AllowMultiple value, and the AttributeUsageAttribute.Inherited value. |
AllowMultiple | Read-write Gets or sets a Boolean value indicating whether more than one instances of the indicated attribute can be specified for a single program element. |
Inherited | Read-write Gets or sets a Boolean value indicating whether the indicated attribute is inherited by derived classes or overridden members. |
TypeId (inherited from System.Attribute) |
Read-only See base class member description: System.Attribute.TypeId When implemented in a derived class, gets a unique identifier for this Attribute. |
ValidOn | Read-only Gets a set of values identifying which program elements that the indicated attribute can be applied to. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetHashCode (inherited from System.Attribute) |
See base class member description: System.Attribute.GetHashCode 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 (inherited from System.Attribute) |
See base class member description: System.Attribute.IsDefaultAttribute When overridden in a derived class, returns an indication whether the value of this instance is the default value for the derived class. |
Match (inherited from System.Attribute) |
See base class member description: System.Attribute.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. |
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:
public AttributeUsageAttribute( |
validOn
For default property values, see the AttributeUsageAttribute.ValidOn, AttributeUsageAttribute.AllowMultiple, and AttributeUsageAttribute.Inherited properties.
namespace System.Runtime.InteropServices { [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)] public class DispIdAttribute: System.Attribute { public DispIdAttribute(int value) { // . . . } public int Value { get { // . . . return 0; } } } }
public bool AllowMultiple {get; set;}
|
public bool Inherited {get; set;}
|
public virtual object TypeId {get;}
|
public AttributeTargets ValidOn {get;}
|
~AttributeUsageAttribute(); |
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.
obj
protected object MemberwiseClone(); |
public virtual string ToString(); |