Share via


Attribute Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Represents the base class for custom attributes.

Inheritance Hierarchy

System. . :: . .Object
  System..::..Attribute
    More...

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<SerializableAttribute> _
<AttributeUsageAttribute(AttributeTargets.All, Inherited := True, AllowMultiple := False)> _
Public MustInherit Class Attribute
[SerializableAttribute]
[AttributeUsageAttribute(AttributeTargets.All, Inherited = true, AllowMultiple = false)]
public abstract class Attribute
[SerializableAttribute]
[AttributeUsageAttribute(AttributeTargets::All, Inherited = true, AllowMultiple = false)]
public ref class Attribute abstract
[<AbstractClass>]
[<SerializableAttribute>]
[<AttributeUsageAttribute(AttributeTargets.All, Inherited = true, AllowMultiple = false)>]
type Attribute =  class end
public abstract class Attribute

The Attribute type exposes the following members.

Constructors

  Name Description
Protected method Attribute Initializes a new instance of the Attribute class.

Top

Methods

  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Remarks

The Attribute class associates predefined system information or user-defined custom information with a target element. A target element can be an assembly, class, constructor, delegate, enum, event, field, interface, method, portable executable file module, parameter, property, return value, struct, or another attribute.

Information provided by an attribute is also known as metadata. Metadata can be examined at run time by your application to control how your program processes data, or before run time by external tools to control how your application itself is processed or maintained. For example, the .NET Framework predefines and uses attribute types to control run-time behavior, and some programming languages use attribute types to represent language features not directly supported by the .NET Framework common type system.

All attribute types derive directly or indirectly from the Attribute class. Attributes can be applied to any target element; multiple attributes can be applied to the same target element; and attributes can be inherited by an element derived from a target element. Use the AttributeTargets class to specify the target element to which the attribute is applied.

The Attribute class provides convenient methods to retrieve and test custom attributes. For more information about using attributes, see Applying Attributes and Extending Metadata Using Attributes.

Thread Safety

This type is thread safe.

See Also

Reference

System Namespace

Inheritance Hierarchy

System. . :: . .Object
  System..::..Attribute
    Microsoft.SPOT. . :: . .FieldNoReflectionAttribute
    Microsoft.SPOT. . :: . .GloballySynchronizedAttribute
    Microsoft.SPOT. . :: . .PublishInApplicationDirectoryAttribute
    Microsoft.SPOT. . :: . .SerializationHintsAttribute
    Microsoft.VisualBasic.CompilerServices. . :: . .DesignerGeneratedAttribute
    Microsoft.VisualBasic.CompilerServices. . :: . .OptionCompareAttribute
    Microsoft.VisualBasic.CompilerServices. . :: . .OptionTextAttribute
    Microsoft.VisualBasic.CompilerServices. . :: . .StandardModuleAttribute
    Microsoft.VisualBasic. . :: . .EmbeddedAttribute
    Microsoft.VisualBasic. . :: . .HideModuleNameAttribute
    System. . :: . .AttributeUsageAttribute
    System. . :: . .CLSCompliantAttribute
    System.ComponentModel. . :: . .EditorBrowsableAttribute
    System.Diagnostics. . :: . .ConditionalAttribute
    System.Diagnostics. . :: . .DebuggableAttribute
    System.Diagnostics. . :: . .DebuggerBrowsableAttribute
    System.Diagnostics. . :: . .DebuggerDisplayAttribute
    System.Diagnostics. . :: . .DebuggerHiddenAttribute
    System.Diagnostics. . :: . .DebuggerNonUserCodeAttribute
    System.Diagnostics. . :: . .DebuggerStepperBoundaryAttribute
    System.Diagnostics. . :: . .DebuggerStepThroughAttribute
    System.Diagnostics. . :: . .DebuggerTypeProxyAttribute
    System. . :: . .FlagsAttribute
    System. . :: . .MTAThreadAttribute
    System. . :: . .NonSerializedAttribute
    System. . :: . .ObsoleteAttribute
    System. . :: . .ParamArrayAttribute
    System.Reflection. . :: . .AssemblyCompanyAttribute
    System.Reflection. . :: . .AssemblyConfigurationAttribute
    System.Reflection. . :: . .AssemblyCopyrightAttribute
    System.Reflection. . :: . .AssemblyCultureAttribute
    System.Reflection. . :: . .AssemblyDefaultAliasAttribute
    System.Reflection. . :: . .AssemblyDelaySignAttribute
    System.Reflection. . :: . .AssemblyDescriptionAttribute
    System.Reflection. . :: . .AssemblyFileVersionAttribute
    System.Reflection. . :: . .AssemblyFlagsAttribute
    System.Reflection. . :: . .AssemblyInformationalVersionAttribute
    System.Reflection. . :: . .AssemblyKeyFileAttribute
    System.Reflection. . :: . .AssemblyKeyNameAttribute
    System.Reflection. . :: . .AssemblyProductAttribute
    System.Reflection. . :: . .AssemblyTitleAttribute
    System.Reflection. . :: . .AssemblyTrademarkAttribute
    System.Reflection. . :: . .AssemblyVersionAttribute
    System.Reflection. . :: . .DefaultMemberAttribute
    System.Runtime.CompilerServices. . :: . .AccessedThroughPropertyAttribute
    System.Runtime.CompilerServices. . :: . .CompilerGeneratedAttribute
    System.Runtime.CompilerServices. . :: . .ExtensionAttribute
    System.Runtime.CompilerServices. . :: . .IndexerNameAttribute
    System.Runtime.CompilerServices. . :: . .InternalsVisibleToAttribute
    System.Runtime.CompilerServices. . :: . .MethodImplAttribute
    System.Runtime.InteropServices. . :: . .ComVisibleAttribute
    System.Runtime.InteropServices. . :: . .GuidAttribute
    System.Runtime.InteropServices. . :: . .OutAttribute
    System.Runtime.InteropServices. . :: . .StructLayoutAttribute
    System.Runtime.Versioning. . :: . .TargetFrameworkAttribute
    System. . :: . .SerializableAttribute
    System. . :: . .STAThreadAttribute
    Ws.ServiceModel. . :: . .DataContractAttribute
    Ws.ServiceModel. . :: . .DataMemberAttribute
    Ws.ServiceModel. . :: . .EnumMemberAttribute
    Ws.ServiceModel. . :: . .MessageParameterAttribute
    Ws.ServiceModel. . :: . .OperationContractAttribute
    Ws.ServiceModel. . :: . .PolicyAssertionAttribute
    Ws.ServiceModel. . :: . .ServiceContractAttribute