This documentation is archived and is not being maintained.

AttributeUsageAttribute.AttributeUsageAttribute Constructor

Initializes a new instance of the AttributeUsageAttribute class with the specified list of AttributeTargets, the AllowMultiple value, and the Inherited value.

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

public AttributeUsageAttribute (
	AttributeTargets validOn
)
public AttributeUsageAttribute (
	AttributeTargets validOn
)
public function AttributeUsageAttribute (
	validOn : AttributeTargets
)
Not applicable.

Parameters

validOn

The set of values combined using a bitwise OR operation to indicate which program elements are valid.

You can combine several AttributeTargets values using a bitwise OR operation to get the desired combination of valid program elements.

For default property values, see the ValidOn, AllowMultiple, and Inherited properties.

The definition of the DispId attribute illustrates the use of a bitwise OR operation to combine several AttributeTargets values.

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;
         }
      }
   }
}

/** @attribute AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | 
    AttributeTargets.Property)
 */
public class DispIdAttribute extends System.Attribute
{    
    public DispIdAttribute(int value)
    {
        //. . .
    } //DispIdAttribute 

    /** @property 
     */
    public int get_Value()
    {
        //. . .
        return 0;
    }//get_Value
} //DispIdAttribute

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0
Show: