How to mark method as "Deprecated"

The attribute Obsolete is used to mark types and members of types that should no longer be used (deprecated).
C# code:
1 [Obsolete("This class is obsolete; use class B instead")]

2 class A

3 {

4 public void F() {}

5 }

6 class B

7 {

8 public void F() {}

9 }

10 class Test

11 {

12 static void Main() {

13 A a = new A(); // Warning

14 a.F();

15 }

16 }


The class A is decorated with the Obsolete attribute. Each use of A in Main results in a warning that includes the specified message, "This class is obsolete; use class B instead."

Visual Basic:

<obsolete("This method is obsolete")> _


Attribute target: class, struct, enum, interface, delegate, method, property, contructor, field, event, not inherited.

Comments

Nam said…
ping back: http://123code.blogspot.com/2010/08/how-to-mark-method-as-deprecated.html
Nam said…
http://123code.blogspot.com/2010/08/how-to-mark-method-as-deprecated.html