This documentation is archived and is not being maintained.

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
)

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 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Show: