Obsolete attribute: warn the user that Method is obsolete : Obsolete Attribute « Attribute « C# / CSharp Tutorial






using System;

class MainClass
{

  
  [Obsolete("Method1 has been replaced by NewMethod1", false)]
  public static int Method1()
  {
    return 1;
  }

  public static void Main() 
  {

    Console.WriteLine(Method1());


  }

}
ObsoleteattributewarntheuserthatMethodisobsolete.cs(18,21): warning CS0618: 'MainClass.Method1()' is
        obsolete: 'Method1 has been replaced by NewMethod1'

1








10.2.Obsolete Attribute
10.2.1.The Obsolete Attribute
10.2.2.Demonstrate the Obsolete attribute.
10.2.3.Obsolete attribute: warn the user that Method is obsolete
10.2.4.Obsolete attribute: throw an error if the user tries to use Method2
10.2.5.Using ObsoleteAttribute