Table of Contents

Class ObsoleteAttribute

Namespace
System
Assembly
mscorlib.dll

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

[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
Inheritance
ObsoleteAttribute
Inherited Members
Extension Methods

Constructors

ObsoleteAttribute()

Initializes a new instance of the ObsoleteAttribute class with default properties.

public ObsoleteAttribute()

ObsoleteAttribute(string)

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

public ObsoleteAttribute(string message)

Parameters

message string

The text string that describes alternative workarounds.

ObsoleteAttribute(string, bool)

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.

public ObsoleteAttribute(string message, bool error)

Parameters

message string

The text string that describes alternative workarounds.

error bool

true if the obsolete element usage generates a compiler error; false if it generates a compiler warning.

Properties

IsError

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

public bool IsError { get; }

Property Value

bool

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.

public string Message { get; }

Property Value

string

The workaround text string.