Export (0) Print
Expand All

ObsoleteAttribute Constructor (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.

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

public ObsoleteAttribute (
	string message,
	bool error
)
public ObsoleteAttribute (
	String message, 
	boolean error
)
public function ObsoleteAttribute (
	message : String, 
	error : boolean
)

Parameters

message

The text string that describes alternative workarounds.

error

The Boolean value that indicates whether the obsolete element usage is considered an error.

The following table shows the initial property values for an instance of ObsoleteAttribute.

Property

Value

IsError

The error value.

Message

The workaround message.

using System;

public class ObsoleteAttrib_Cons1
{

   // Mark the method as 'Obsolete' with message and IsError as parameters.
   [ObsoleteAttribute("This function will be removed from future Versions.Use another function 'NewFunction'",false)]
   public string OldFunction()
   {
      return "This is the String from old function.";
   }
   // Create the another function which is replacement to the 'OldFunction'.
   public string NewFunction()
   {
      return "This is the String from new function.";
   }

}
public class TestObsolete3
{
   static void Main(string[] args)
   {            
      try
      {
         ObsoleteAttrib_Cons1 myObsolete = new ObsoleteAttrib_Cons1();
         Console.WriteLine(myObsolete.OldFunction());
         Console.WriteLine(myObsolete.NewFunction());
      }
      catch(Exception e)
      {
         Console.WriteLine("The Exception is :"+e.Message);
      }
   }
}

import System.*;
public class ObsoleteAttrib_Cons1
{
    // Mark the method as 'Obsolete' with message and IsError as parameters.
    /** @attribute ObsoleteAttribute("This function will be removed from future"
       + "Versions.Use another function 'NewFunction'", false)
     */
    public String OldFunction()
    {
        return "This is the String from old function.";
    } //OldFunction

    // Create the another function which is replacement to the 'OldFunction'.
    public String NewFunction()
    {
        return "This is the String from new function.";
    } //NewFunction
} //ObsoleteAttrib_Cons1

public class TestObsolete3
{
    public static void main(String[] args)
    {
        try {
            ObsoleteAttrib_Cons1 myObsolete = new ObsoleteAttrib_Cons1();
            Console.WriteLine(myObsolete.OldFunction());
            Console.WriteLine(myObsolete.NewFunction());
        }
        catch (System.Exception e) {
            Console.WriteLine("The Exception is :" + e.get_Message());
        }
    } //main
} //TestObsolete3

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