Mega Code Archive

 
Categories / C# / Language Basics
 

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