Obsolete attribute : Obsolete Attribute : Attribute C# Examples


C# Examples » Attribute » Obsolete Attribute »

 

Obsolete attribute









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


    }

}
    
   
  
   



Output

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

1


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Attribute
» Obsolete Attribute