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 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.Attribute System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Enum | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Field | System.AttributeTargets.Event | System.AttributeTargets.Interface | System.AttributeTargets.Delegate | System.AttributeTargets.All, Inherited=false) System.Runtime.InteropServices.ComVisible(true)

Indicates that the target of the current attribute will be removed in future versions of the assembly in which the target is contained.

Marking an item as obsolete provides consumers of that item the information that the item will be not be available in future versions of the assembly in which it is contained. A has a property that can be used to suggest alternative ways of obtaining the functionality provided by the item, i.e. a workaround. This class also has a property that designates whether a compiler will treat usage of the obsolete item as an error. If this property is , the compiler will issue a warning if the obsolete item is used and the compiler supports the generation of such warnings.

This attribute can be applied to any valid attribute target except assemblies, parameters, and return values. For a complete list of valid attribute targets, see .

The following example demonstrates the usage of to generate a compile-time warning.

`using System; public class ObsoleteAttributeExample { [ObsoleteAttribute("OldMethod is being removed: use NewMethod in future versions.")] public static void OldMethod() { //Execute some code here } public static void Main() { OldMethod(); } }`

An example compile-time result is

ObsoleteAttributeExample.cs(8,4): warning CS0618: 'ObsoleteAttributeExample.OldMethod()' is obsolete: 'OldMethod is being removed: use NewMethod in future versions.'

- Constructor

  Constructs and initializes a new instance of the class.

  This constructor is equivalent to (, ). The compiler does not treat an item with this attribute as an error.

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Constructor
  The that contains suggested workarounds.

  Constructs and initializes a new instance of the class with the specified that contains suggested workarounds.

  This constructor is equivalent to ( , ). The compiler does not treat an item with this attribute as an error.

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Constructor
  A that contains suggested workarounds.
  A that indicates whether the compiler treats usage of the target of the current instance as an error.

  Constructs and initializes a new instance of the class with a that contains suggested workarounds and a that indicates whether the compiler treats usage of the target of the current instance as an error.

  Respectively, the property and the property of the new instance are initialized as and .

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Property
  System.Boolean

  Gets a that indicates whether the compiler treats usage of the target of the current instance as an error.

  if the compiler treats usage of the target of the current instance as an error; otherwise, .

  This property is read-only.

  The default value of this property is .

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Property
  System.String

  Gets a that contains suggested workarounds for the target of the current instance.

  A that contains suggested workarounds for the target of the current instance.

  This property is read-only.

  The current instance contains a suggested workaround message if and only if such a message was specified when the current instance was constructed. If no workaround was specified for the current instance, the value of this property is .

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
0