System.AttributeTargets Enum

public enum AttributeTargets

Base Types

Object
  ValueType
    Enum
      AttributeTargets

Assembly

mscorlib

Library

BCL

Summary

Enumerates the application elements to which it is valid to attach an attribute.

Description

AttributeTargets is used as a parameter for AttributeUsageAttribute to enable an attribute to be associated with one or more kinds of application elements.

Example

The following example demonstrates how AttributeTargets can be used with AttributeUsageAttribute so that a user-defined attribute class, Author, can be applied to structures and classes. The Author attribute is then applied to a class. There is no output.

using System;

[AttributeUsageAttribute(AttributeTargets.Class|
                         AttributeTargets.Struct)]
public class Author : Attribute {

   public Author(string Name) {
 
     this.name = Name; }
     string name;
   }

[Author("John Q Public")]
class JohnsClass {

   public static void Main() {
   }
}

Attributes

FlagsAttribute

See Also

System Namespace

Members

AttributeTargets Fields

AttributeTargets.All Field
AttributeTargets.Assembly Field
AttributeTargets.Class Field
AttributeTargets.Constructor Field
AttributeTargets.Delegate Field
AttributeTargets.Enum Field
AttributeTargets.Event Field
AttributeTargets.Field Field
AttributeTargets.GenericParameter Field
AttributeTargets.Interface Field
AttributeTargets.Method Field
AttributeTargets.Module Field
AttributeTargets.Parameter Field
AttributeTargets.Property Field
AttributeTargets.ReturnValue Field
AttributeTargets.Struct Field
AttributeTargets.value__ Field


AttributeTargets.All Field

All = Assembly | 0x2 | Class | Struct | Enum | Constructor | Method | Property | Field | Event | Interface | Parameter | Delegate | ReturnValue | GenericParameter;

Summary

Attribute can be applied to any element.

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.Assembly Field

Assembly = 0x1;

Summary

Attribute can be applied to an assembly.

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.Class Field

Class = 0x4;

Summary

Attribute can be applied to a class.

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.Constructor Field

Constructor = 0x20;

Summary

Attribute can be applied to a constructor.

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.Delegate Field

Delegate = 0x1000;

Summary

Attribute can be applied to a delegate.

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.Enum Field

Enum = 0x10;

Summary

Attribute can be applied to an enumeration.

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.Event Field

Event = 0x200;

Summary

Attribute can be applied to an event.

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.Field Field

Field = 0x100;

Summary

Attribute can be applied to a field.

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.GenericParameter Field

GenericParameter = 0x4000;

Summary

Attribute can be applied to a generic Parameter.

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.Interface Field

Interface = 0x400;

Summary

Attribute can be applied to an interface.

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.Method Field

Method = 0x40;

Summary

Attribute can be applied to a method.

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.Module Field

Module = 0x2;

Summary

Attribute can be applied to a module.

Library

RuntimeInfrastructure

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.Parameter Field

Parameter = 0x800;

Summary

Attribute can be applied to a parameter.

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.Property Field

Property = 0x80;

Summary

Attribute can be applied to a property.

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.ReturnValue Field

ReturnValue = 0x2000;

Summary

Attribute can be applied to a return value.

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.Struct Field

Struct = 0x8;

Summary

Attribute can be applied to a value type.

See Also

System.AttributeTargets Enum, System Namespace

AttributeTargets.value__ Field

value__;

See Also

System.AttributeTargets Enum, System Namespace