Obsolete attribute : Obsolete Attribute : Attribute C# Examples


C# Examples » Attribute » Obsolete Attribute »

 

Obsolete attribute









    
using  System;

class  MainClass
{
    
    [Obsolete("Method2  has  been  replaced  by  NewMethod2",  true)]
    public  static  int  Method2()
    {
        return  2;
    }

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

}
    
   
  
   



Output

ObsoleteattributethrowanerroriftheusertriestouseMethod2.cs(16,21): error CS0619:
        'MainClass.Method2()' is obsolete: 'Method2 has been replaced by NewMethod2'


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Attribute
» Obsolete Attribute