OCDProgrammer.com

It's Microsoft's World, and I'm just living in it
View Clarence Klopfstein's profile on LinkedIn

Clarence Klopfstein's Facebook profile

This site is under construction...

Categories

New Comments

Referring Sites


Disclaimer

  • This is MY blog. The views represented here are not in relation to anybody else. Please read my full disclaimer for a more complete disclaimer.

Deprecated functions in .NET

October 10, 2008 03:00 by ckincincy

When I started at my employer I inherited a bit of code that was poor at best.  Over the year I've been working with it, I've been refactoring the code significantly. 

Then we hired another developer and this process sped up a bit and I needed to mark some classes as deprecated.  So over time old code could be replaced with the new code.  I've done this before, but had to do a quick search and as an FYI here is the answer:

[Obsolete("Deprecated: Use GetCustomerID", false)]
public int GetCustomer(int custId)
{
           .... code in here

}

The first parameter is the warning/error message to show in the compiler.  The second option is whether or not to cause an error.  So basically you can say, this is broke don't use it.  Or this is old, use something else.  The first breaks the code, the second allows it to go on for a bit.

HT: Karpach.com


Comments are closed