ObsoleteAttribute.IsError プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ObsoleteAttribute.IsError プロパティの意味・解説 

ObsoleteAttribute.IsError プロパティ

今後使用しないマークしたプログラム要素使用され場合に、コンパイラエラーとして処理するかどうかを示す Boolean 値を取得します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

使用例使用例
Imports System
Imports System.ComponentModel
Imports Microsoft.VisualBasic



Public Class ObsoleteAttribute_Message
   
   ' Mark the property as 'Obsolete' with message and IsError as parameters.
   
<ObsoleteAttribute("This property will be removed from
 future Versions.Use another property 'MyNewProperty'",
 False)> _
   Public ReadOnly Property
 MyOldProperty() As String
      Get
         Return "This is the value of the property"
      End Get
   End Property
   ' Create another property.
   
   Public ReadOnly Property
 MyNewProperty() As String
      Get
         Return "This is the value of the new
 property"
      End Get
   End Property
   
   
   ' Get the Properties of the 'ObsoleteAttribute'.  
   Public Sub GetPropertyAttributes()
      ' Retrieve all the attributes.
      Dim attributes As AttributeCollection
 = TypeDescriptor.GetProperties(Me)("MyOldProperty").Attributes
      
      Dim myAttribute As ObsoleteAttribute
 = CType(attributes(GetType(ObsoleteAttribute)), ObsoleteAttribute)
      Console.WriteLine(("The Message of the ObsoleteAttribute
 is :" + ControlChars.Cr + myAttribute.Message))
      Console.WriteLine(("Usage of Obsolete as error is :"
 + myAttribute.IsError.ToString()))
   End Sub 'GetPropertyAttributes
   
   'Entry point which delegates to C-style main Private Function
   Public Overloads Shared
 Sub Main()
      Main(System.Environment.GetCommandLineArgs())
   End Sub
   
   
   Overloads Shared Sub
 Main(args() As String)
      
      Try
         Dim myObsolete As New
 ObsoleteAttribute_Message()
         Console.WriteLine(("The Message of Old Property is :"
 + myObsolete.MyOldProperty))
         Console.WriteLine(("The Message of New Property is :"
 + myObsolete.MyNewProperty))
         Console.WriteLine(ControlChars.Cr + "The Values of ObsoleteAttribute
 are:")
         myObsolete.GetPropertyAttributes()
      
      Catch e As Exception
         Console.WriteLine(("The Exception is :" +
 e.Message.ToString()))
      End Try
   End Sub 'Main 
End Class 'ObsoleteAttribute_Message
using System;
using System.ComponentModel;

public class ObsoleteAttribute_Message
{
// Mark the property as 'Obsolete' with message and IsError as parameters.
[ObsoleteAttribute("This property will be removed from future Versions.Use another
 property 'MyNewProperty'",false)]
   public string MyOldProperty 
   {
      get 
      {
         return "This is the value of the property";
      }
   }
   // Create another property.
   public string MyNewProperty 
   {
      get 
      {
         return "This is the value of the new
 property";
      }
   }


// Get the Properties of the 'ObsoleteAttribute'.  
public void GetPropertyAttributes()
{
   // Retrieve all the attributes.
   AttributeCollection attributes = TypeDescriptor.GetProperties(this)["MyOldProperty"].Attributes;
       
   ObsoleteAttribute myAttribute = (ObsoleteAttribute)attributes[typeof(ObsoleteAttribute)];
   Console.WriteLine("The Message of the ObsoleteAttribute is :\n"+myAttribute.Message);
   Console.WriteLine("Usage of Obsolete as error is :"+myAttribute.IsError);
}
}

public class TestObsolete4
{
   static void Main(string[]
 args)
   {                 
      try
      {
         ObsoleteAttribute_Message myObsolete = new ObsoleteAttribute_Message();
         Console.WriteLine("The Message of Old Property is :"+myObsolete.MyOldProperty);
         Console.WriteLine("The Message of New Property is :"+myObsolete.MyNewProperty);
         myObsolete.GetPropertyAttributes();
      }
      catch(Exception e)
      {
         Console.WriteLine("The Exception is :"+e.Message);
      }                     
   } 

}
#using <system.dll>

using namespace System;
using namespace System::ComponentModel;

public ref class ObsoleteAttribute_Message
{
public:

   property String^ MyOldProperty 
   {
      // Mark the property as 'Obsolete' with message and IsError as
 parameters.

      [ObsoleteAttribute("This property will be removed from future Versions.
 Use another property 'MyNewProperty'",false)]
      String^ get()
      {
         return "This is the value of the property";
      }
   }

   property String^ MyNewProperty 
   {
      // Create another property.
      String^ get()
      {
         return "This is the value of the new
 property";
      }
   }

   // Get the Properties of the 'ObsoleteAttribute'.  
   void GetPropertyAttributes()
   {
      // Retrieve all the attributes.
      AttributeCollection^ attributes = TypeDescriptor::GetProperties( this
 )[ "MyOldProperty" ]->Attributes;
      ObsoleteAttribute^ myAttribute = safe_cast<ObsoleteAttribute^>(attributes[
 ObsoleteAttribute::typeid ]);
      Console::WriteLine( "The Message of the ObsoleteAttribute is :\n {0}",
 myAttribute->Message );
      Console::WriteLine( "Usage of Obsolete as error is : {0}", myAttribute->IsError
 );
   }
};

int main()
{
   try
   {
      ObsoleteAttribute_Message^ myObsolete = gcnew ObsoleteAttribute_Message;
      Console::WriteLine( "The Message of Old Property is : {0}", myObsolete->MyOldProperty
 );
      Console::WriteLine( "The Message of New Property is : {0}", myObsolete->MyNewProperty
 );
      myObsolete->GetPropertyAttributes();
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "The Exception is : {0}", e->Message );
   }
}
import System.*;
import System.ComponentModel.*;
public class ObsoleteAttribute_Message
{
    // Mark the property as 'Obsolete' with message and IsError as parameters.
    /** @attribute ObsoleteAttribute("This property will be removed from future"
        + "Versions.Use another property 'MyNewProperty'", false)
     */

    /** @property
     */
    public String get_MyOldProperty()
    {
        return "This is the value of the property";
    } //get_MyOldProperty

    // Create another property.
    
    /** @property 
     */
    public String get_MyNewProperty()
    {
        return "This is the value of the new
 property";
    } //get_MyNewProperty

    // Get the Properties of the 'ObsoleteAttribute'.  
    public void GetPropertyAttributes()
    {
        // Retrieve all the attributes.
        AttributeCollection attributes = TypeDescriptor.GetProperties(this).
            get_Item("MyOldProperty").get_Attributes();

        ObsoleteAttribute myAttribute = (ObsoleteAttribute)(attributes.
            get_Item(ObsoleteAttribute.class.ToType()));
        Console.WriteLine("The Message of the ObsoleteAttribute is :\n"
            + myAttribute.get_Message());
        Console.WriteLine("Usage of Obsolete as error is :" 
            + myAttribute.get_IsError());
    } //GetPropertyAttributes
} //ObsoleteAttribute_Message

public class TestObsolete4
{
    public static void main(String[]
 args)
    {
        try {
            ObsoleteAttribute_Message myObsolete = 
                new ObsoleteAttribute_Message();
            Console.WriteLine("The Message of Old Property is :" 
                + myObsolete.get_MyOldProperty());
            Console.WriteLine("The Message of New Property is :"
                + myObsolete.get_MyNewProperty());
            myObsolete.GetPropertyAttributes();
        }
        catch (System.Exception e) {
            Console.WriteLine("The Exception is :" + e.get_Message());
        }
    } //main
} //TestObsolete4
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ObsoleteAttribute クラス
ObsoleteAttribute メンバ
System 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からObsoleteAttribute.IsError プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からObsoleteAttribute.IsError プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からObsoleteAttribute.IsError プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

ObsoleteAttribute.IsError プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ObsoleteAttribute.IsError プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS