Mark you code as Obsolete in c#

Posted by Madhu.b.rokkam under C# category on | Points: 40 | Views : 2693
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.


[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