KARPACH

WEB DEVELOPER BLOG

How to mark a method as deprecated?

In computer software standards and documentation, the term deprecation is applied to software features that are superseded and should be avoided. Although deprecated features remain in the current version, their use may raise warning messages recommending alternate practices, and deprecation may indicate that the feature will be removed in the future. Features are deprecated—rather than being removed to provide backward compatibility and give programmers using the feature time to bring their code into compliance with the new standard. You can mark your own methods as deprecated:

[Obsolete("Use New Version with Textonly email version")]
public DataTable GetReminderEmailsForToday()
{
    ....
}
Posted on May 12, 2008 by

Comments

Posted on 8/19/2008 06:13:33 AM by Jim

Very helpful. Thanks.

Posted on 9/25/2008 12:58:12 PM by Carlos

Thanks!

Posted on 2/17/2009 05:20:36 AM by Mudi_mora

thanks ,,its help a lot since im developing sdks

Posted on 8/20/2009 01:28:49 AM by dvd

If I mark an abstract method as deprecated, do I have to do this for all the places I override it ?
Yes, otherwise it will give you a warning only at place where you are overriding it.

Posted on 3/22/2010 05:28:14 AM by haxpor

Thanks !

Posted on 6/2/2010 04:33:06 AM by sumit

thanks

Posted on 12/9/2011 09:59:03 AM by Chuck

There is an optional parameter which will cause it to throw a compile time error as well.

[Obsolete("This will throw a compile time exception.", true)]

Posted on 12/19/2011 08:19:13 AM by Tony

I do this just rarely enough I can never remember what the tag is, so I still go back to this post everytime. Great reference post. Thanks!

Posted on 10/8/2012 05:15:07 AM by 80s Arcade

A Winner Is You!

Posted on 4/17/2013 12:35:17 PM by FlingDang

Thanks for the tip! Hard to find the post among all the ads, but helpful nonetheless!