How to mark a class as Deprecated?

The reason to not erase a class and deprecate instead is to adhere to some "politeness policies" when your code is an estabished API and then is consumed by third parties.

If you deprecate instead of erase, you give consumers a life cycle policy (e.g., maintenance and existence of the classes until version X.X) in order to allow them to plan a proper migration to your new API.


As per Doak's answer, but the attribute's second parameter should be set to false if you want the code to compile:

[Obsolete("Not used any more", false)]
public class MyDeprecatedClass
{
        //...
}

This will just throw warnings.


You need to use the [Obsolete] attribute.

Example:

[Obsolete("Not used any more", true)]
public class MyDeprecatedClass
{
    //...
}

The parameters are optional. The first parameter is for providing the reason it's obsolete, and the last one is to throw an error at compile time instead of a warning.