ObsoleteAttribute クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<SerializableAttribute> _ <ComVisibleAttribute(True)> _ <AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Struct Or AttributeTargets.Enum Or AttributeTargets.Constructor Or AttributeTargets.Method Or AttributeTargets.Property Or AttributeTargets.Field Or AttributeTargets.Event Or AttributeTargets.Interface Or AttributeTargets.Delegate, Inherited:=False)> _ Public NotInheritable Class ObsoleteAttribute Inherits Attribute
[SerializableAttribute] [ComVisibleAttribute(true)] [AttributeUsageAttribute(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
[SerializableAttribute] [ComVisibleAttribute(true)] [AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Struct|AttributeTargets::Enum|AttributeTargets::Constructor|AttributeTargets::Method|AttributeTargets::Property|AttributeTargets::Field|AttributeTargets::Event|AttributeTargets::Interface|AttributeTargets::Delegate, Inherited=false)] public ref class ObsoleteAttribute sealed : public Attribute
/** @attribute SerializableAttribute() */ /** @attribute ComVisibleAttribute(true) */ /** @attribute AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Constructor|AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Event|AttributeTargets.Interface|AttributeTargets.Delegate, Inherited=false) */ public final class ObsoleteAttribute extends Attribute
SerializableAttribute ComVisibleAttribute(true) AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Constructor|AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Event|AttributeTargets.Interface|AttributeTargets.Delegate, Inherited=false) public final class ObsoleteAttribute extends Attribute

ObsoleteAttribute は、アセンブリ、モジュール、パラメータ、戻り値を除くすべてのプログラム要素に適用できます。要素に旧式としてマーク付けすることで、この要素が製品の将来のバージョンで廃止されることをユーザーに知らせることができます。

ObsoleteAttribute でマークされたメソッドが含まれるクラスを定義する例を次に示します。このメソッドを呼び出すコードでは、コンパイラによって警告が出力されます。
using System; public sealed class App { static void Main() { // The line below causes the compiler to issue a warning: // 'App.SomeDeprecatedMethod()' is obsolete: 'Do not call this method.' SomeDeprecatedMethod(); } // The method below is marked with the ObsoleteAttribute. // Any code that attempts to call this method will get a warning. [Obsolete("Do not call this method.")] private static void SomeDeprecatedMethod() { } }
using namespace System; // The method below is marked with the ObsoleteAttribute. // Any code that attempts to call this method will get a warning. [Obsolete("Do not call this method.")] void SomeDeprecatedMethod() { } int main() { // The line below causes the compiler to issue a warning: // 'SomeDeprecatedMethod()': marked as obsolete // Message: 'Do not call this method.' SomeDeprecatedMethod(); }

System.Attribute
System.ObsoleteAttribute


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- ObsoleteAttribute クラスのページへのリンク