C# - Selectively suppress custom Obsolete warnings

后端 未结 4 1741
小鲜肉
小鲜肉 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:17

    You're looking for the #pragma warning disable directive

    • http://msdn.microsoft.com/en-us/library/441722ys(VS.80).aspx

    Essentially you add the following command above the call site in the .cs file.

    #pragma warning disable 612
    SomeMethodCall
    

    612 is the error message ID for calling obsolete methods

提交回复
热议问题