Class ObsoleteAttribute
Marks the program elements that are no longer in use. This class cannot be inherited.
Inherited Members
Namespace: System
Assembly: mscorlib.dll
Syntax
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
public sealed class ObsoleteAttribute : Attribute
Constructors
| Improve this Doc View SourceObsoleteAttribute()
Initializes a new instance of the ObsoleteAttribute class with default properties.
Declaration
public ObsoleteAttribute()
ObsoleteAttribute(String)
Initializes a new instance of the ObsoleteAttribute class with a specified workaround message.
Declaration
public ObsoleteAttribute(string message)
Parameters
Type | Name | Description |
---|---|---|
String | message | The text string that describes alternative workarounds. |
ObsoleteAttribute(String, Boolean)
Initializes a new instance of the ObsoleteAttribute class with a workaround message and a Boolean value indicating whether the obsolete element usage is considered an error.
Declaration
public ObsoleteAttribute(string message, bool error)
Parameters
Type | Name | Description |
---|---|---|
String | message | The text string that describes alternative workarounds. |
Boolean | error | true if the obsolete element usage generates a compiler error; false if it generates a compiler warning. |
Properties
| Improve this Doc View SourceIsError
Gets a Boolean value indicating whether the compiler will treat usage of the obsolete program element as an error.
Declaration
public bool IsError { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the obsolete element usage is considered an error; otherwise, false. The default is false. |
Message
Gets the workaround message, including a description of the alternative program elements.
Declaration
public string Message { get; }
Property Value
Type | Description |
---|---|
String | The workaround text string. |