Demonstrate the Obsolete attribute. : Obsolete Attribute : Attribute C# Examples


C# Examples » Attribute » Obsolete Attribute »

 

Demonstrate the Obsolete attribute.









    
using  System;  
  
class  MainClass  {  
  
    [Obsolete("Use  myMeth2,  instead.")]    
    static  int  myMethod(int  a,  int  b)  {  
        return  0;  
    }  
  
    //  Improved  version  of  myMethod.  
    static  int  myMethod2(int  a,  int  b)  {  
        return  1;  
    }  
  
    public  static  void  Main()  {  
      //  warning  displayed  for  this  
        Console.WriteLine("4  /  3  is  "  +  myMethod(4,  3));  
  
      //  no  warning  here  
        Console.WriteLine("4  /  3  is  "  +  myMethod2(4,  3));    
    }  
}
    
   
  
   



Output

4 / 3 is 0
4 / 3 is 1


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Attribute
» Obsolete Attribute