BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 System.Enum System.Flags System.Runtime.InteropServices.ComVisible(true)

The following example demonstrates how can be used with so that a user-defined attribute class, , can be applied to structures and classes. The 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() { } }`

The class uses this enumeration to specify the kind of element on which it is valid to apply an attribute.

enumeration values can be combined with a bitwise OR operation to get the preferred combination.

Specifies the application elements on which it is valid to apply an attribute.

- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.AttributeTargets All To be added.

  Attribute can be applied to any application element.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.AttributeTargets Assembly To be added.

  Attribute can be applied to an assembly.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.AttributeTargets Class To be added.

  Attribute can be applied to a class.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.AttributeTargets Constructor To be added.

  Attribute can be applied to a constructor.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.AttributeTargets Delegate To be added.

  Attribute can be applied to a delegate.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.AttributeTargets Enum To be added.

  Attribute can be applied to an enumeration.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.AttributeTargets Event To be added.

  Attribute can be applied to an event.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.AttributeTargets Field To be added.

  Attribute can be applied to a field.

  0
- Field
  2.0.0.0
  4.0.0.0
  System.AttributeTargets

  Currently, this attribute can be applied only in C#, Microsoft intermediate language (MSIL), and emitted code.

  Attribute can be applied to a generic parameter.

- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.AttributeTargets Interface To be added.

  Attribute can be applied to an interface.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.AttributeTargets Method To be added.

  Attribute can be applied to a method.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.AttributeTargets Module

  refers to a portable executable file (.dll or.exe) and not a Visual Basic standard module.

  Attribute can be applied to a module.

  1
  RuntimeInfrastructure
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.AttributeTargets Parameter To be added.

  Attribute can be applied to a parameter.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.AttributeTargets Property To be added.

  Attribute can be applied to a property.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.AttributeTargets ReturnValue To be added.

  Attribute can be applied to a return value.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.AttributeTargets Struct To be added.

  Attribute can be applied to a structure; that is, a value type.

  0
0