Mark you code as Obsolete in c#

Madhu.b.rokkam
Posted by Madhu.b.rokkam under C# category on | Points: 40 | Views : 3494
At times when we create a new code block for an existing class/function/method and want all to use that instead of the old one, And also since you cannot delete it since that is being used in some other parts, we need to set that class/method as obsolete so that we can specify others to use the new one.

We need to mark the method or class with the [Obsolete] attribute.

Ex:

[Obsolete("Don't use this because...Some reason here")]
class MyClass { }


If you want to error out then]

[Obsolete("Don't use this because..Some reason.", true)]
class MyClass { }

Comments or Responses

Login to post response