Demonstrate the Obsolete attribute : Attribute : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Attribute »

 

Demonstrate the Obsolete attribute









    


// Demonstrate the Obsolete attribute. 
 
using System; 
 
public class TestAno1 { 
 
  [Obsolete("Use myMeth2, instead.")]  
  static int myMeth(int a, int b) { 
    return a / b; 
  } 
 
  // Improved version of myMeth. 
  static int myMeth2(int a, int b) { 
    return b == 0 ? 0 : a /b; 
  } 
 
  public static void Main() { 
    Console.WriteLine("4 / 3 is " + TestAno1.myMeth(4, 3)); 
 
    Console.WriteLine("4 / 3 is " + TestAno1.myMeth2(4, 3));  
  } 
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Attribute