Export (0) Print
Expand All

ObsoleteAttribute.Message Property

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

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public string Message { get; }
/** @property */
public String get_Message ()

public function get Message () : String

Property Value

The workaround text string.

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);
      }                     
   } 

}

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

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft