Illustrates use of the Obsolete attribute : Attribute : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Attribute »

 

Illustrates use of the Obsolete attribute








    


/*
illustrates use of the Obsolete attribute
*/

using System;

public class Example17_1 
{
  // warn the user that Method1 is obsolete
  [Obsolete("Method1 has been replaced by NewMethod1", false)]
  public static int Method1()
  {
    return 1;
  }

  // throw an error if the user tries to use Method2
  [Obsolete("Method2 has been replaced by NewMethod2", true)]
  public static int Method2()
  {
    return 2;
  }

  public static void Main() 
  {
    Console.WriteLine(Method1());
    Console.WriteLine(Method2());
  }
}




           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Attribute