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)

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.'

is applicable to all program elements except assemblies, modules, parameters, and return values. Marking an element as obsolete informs users that the element will be removed in future versions of the product.

The class includes two properties:

. The string assigned to the property is emitted by the compiler when the attribute target is used in code. The string should note that the attribute target is obsolete and, if possible, provide some workaround or programmatic alternative.

. This is a Boolean value that indicates to the compiler whether using the attribute should cause it to emit an error ( is true) or a warning ( is false).

For more information about using attributes, see [<topic://cpconExtendingMetadataUsingAttributes>].

## win8_appname_long Apps

When you create a Windows Metadata library (.winmd file), the is exported as both the attribute and the Windows.Foundation.Metadata.DeprecatedAttribute attribute if only the is present in source code. The is transformed to the DeprecatedAttribute as follows:

If the and arguments are both present, is assigned to the DeprecatedAttribute argument. An error value of true maps to DeprecationType.Remove, and an value of false maps to DeprecationType.Deprecate.

If the argument is not supplied in the , its default value in the DeprecatedAttribute is "element_name is deprecated", where element_name is the name of the target program element to which the attribute is applied.

If the argument is not present in the , its default value in the DeprecatedAttribute is DeprecationType.Deprecate.

Directly applying the Windows.Foundation.Metadata.DeprecatedAttribute attribute to managed code is not recommended, because this export occurs automatically.

Marks the program elements that are no longer in use. This class cannot be inherited.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The following table shows the initial property values for an instance of .

  Property

  Value

  false

  null

  Initializes a new instance of the class with default properties.

  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The following table shows the initial property values for an instance of .

  Property

  Value

  false.

  The workaround message.

  Initializes a new instance of the class with a specified workaround message.

  The text string that describes alternative workarounds.
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The following table shows the initial property values for an instance of .

  Property

  Value

  The value.

  The workaround message.

  Initializes a new instance of the class with a workaround message and a Boolean value indicating whether the obsolete element usage is considered an error.

  The text string that describes alternative workarounds.
  The Boolean value that indicates whether the obsolete element usage is considered an error.
  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean

  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 .

  Gets a Boolean value indicating whether the compiler will treat usage of the obsolete program element as an error.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  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 .

  Gets the workaround message, including a description of the alternative program elements.

  0
0