Friday, October 12, 2007

DotNet Code Attributes - Obsolescing Your Code

In C#:

[ObsoleteAttribute("This method is obsolete. Please use Retrieve(iID) instead",

false)]

public DataSet Retrieve(string sProduct)

{

// Code here performs the retrieve

}

The first parameter of the ObsoleteAttribute is the message text that the developer

will see wherever the obsolete method is used. This message text will appear in the Task

List window.

The second parameter of the ObsoleteAttribute is whether the obsolete member usage

is considered to be an error. Set the parameter to False to specify that the developer using

the method will get a warning message in the Task List window, or to True to generate a

syntax error if the method is used.

Extracts from the eBook:

Best Kept Secrets in .NET

DEBORAH KURATA

No comments:

Post a Comment

Creative Commons License
This work by Tito is licensed under a Creative Commons Attribution 3.0 Unported License.