How to

mark type or member as obsolete (deprecated)

Published: 27. January 2009 | Updated: 9. October 2011
License: Microsoft Public License (MS-PL)
Categories: Framework » Attributes
Tags: Attributes C# Visual Studio
Was this snippet helpful for you? YESYES / NONO

Obsolete attribute can be used on class, struct, enum, interface, delegate, method, constructor, property, field or event.
// generates warning when calling this method
[Obsolete("This method is obsolete; use method XYZ instead")]
public static string EscapeText(string input)
{
    ...
}

// Passing 'true' as second parameter will generate error instead of warning whenever the method is called
[Obsolete("This method is obsolete; use method XYZ instead", true)]
public static string EscapeText(string input)
{
    ...
}
Send us feedback about this snippet »



Related Snippets: