VisualStudio C# How to Suppress Warnings and Find Warning Numbers

Sometimes it is useful to suppress certain warnings in a certain piece of code. It is done like this:

#pragma warning disable 414, 302
   // hic sunt leones
#pragma warning restore 414, 302

But to disable a certain warning, you first need to know its number. Finding out this number is not easy if you don’t know how to.

The following resolution is copied from Stackoverflow, just as a reference for me, because I needed too much time to find the information in the first place. So here is how to find out C# warning numbers in VS2012:

The Error List hides the error and warning numbers, but if you open the **Output panel** in Visual Studio (menu : Debug > Windows > Output) and set it to show **output from Build**, you can find the warning number somewhere in the wall of text.

You could also try building the project from the command line (using msbuild) which will output and highlight all error and warning numbers.

Leave a Reply

Your email address will not be published.