Is there an attribute like Obsolete
or Deprecated
to indicate that a method has become obsolete or deprecated in the next version of a C# API? Otherwise, is there a standard for indicating that, like adding it in the remarks of a method's documentation?
You should mark the method as obsolete using the Obsolete annotation. Refer to ObsoleteAttribute for details.
[Obsolete("Your warning message")]
public void MyMethod()
{
// Method body
}
If you want to throw an error instead of a warning, you could set the second argument error which is a boolean to true .
[Obsolete("Your error message", true)]
public void MyMethod()
{
// Method body
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.