C# - Selectively suppress custom Obsolete warnings

后端 未结 4 1732
小鲜肉
小鲜肉 2020-11-28 05:04

I\'m using the Obsolete attribute (as just suggested by fellow programmers) to show a warning if a certain method is used.

Is there a way to suppress the

4条回答
  •  难免孤独
    2020-11-28 05:31

    Here's how to get the warning/error number in the first place:

    1. Rebuild your project.
    2. Go to the Output window.
    3. Look up the line of the warning/error you want to suppress.
      For example:
      C:\Users\Username\Documents\Visual Studio 2010\Projects\Projectname\Classname.cs(203,7): warning CS0162: Unreachable code detected
    4. Copy the number part after "CS".
    5. Then proceed as Jon Skeet says.

    (Better always proceed as Jon Skeet says…)

提交回复
热议问题