Illustrates use of the Obsolete attribute
/*
illustrates use of the Obsolete attribute
*/
using System;
public class Example17_1
{
// warn the user that Method1 is obsolete
[Obsolete("Method1 has been replaced by NewMethod1", false)]
public static int Method1()
{
return 1;
}
// throw an error if the user tries to use Method2
[Obsolete("Method2 has been replaced by NewMethod2", true)]
public static int Method2()
{
return 2;
}
public static void Main()
{
Console.WriteLine(Method1());
Console.WriteLine(Method2());
}
}
Related examples in the same category