views:

2157

answers:

5

The syntax for disabling warnings is as follows:

#pragma warning disable 414, 3021

Or, expressed more generally:

#pragma warning disable [CSV list of numeric codes]

Is there a list of these numeric codes and the description of the warning that they're suppressing? Much to my chagrin, I can't seem to locate it via Google.

+2  A: 

Look down the list of C# compiler errors and warnings to find the individual warning numbers.

Jeffrey Hantin
Here is a more complete list: http://msdn.microsoft.com/en-us/library/ms228296%28v=VS.90%29.aspx
Restuta
+5  A: 

You shouldn't need a list. The compiler will tell you. If you get a compiler error that says "warning CS0168", then add 168 to the list (or, better yet, fix the code).

Joe White
The important point here being to look at the Output tab ("Build" in particular"), not the Error List. Or just use msbuild/csc. But +1; that's what I do ;-p
Marc Gravell
+5  A: 

MSDN has a list of warning codes. Unfortunately, you have to click each link to view what the code actually means.

MiffTheFox
+2  A: 

FYI -

If you're using Visual Studio 2008, you can get the code directly from the Error List by right-clicking the error, and selecting Show Error Help from the context menu. The Help window should pop up, and show you everything you ever wanted to know about the error a la the MSDN website.

Could save you a bit of time.

Syndog
You can also get the error code by looking at the Output tab, which eliminates the need to open Help which can sometimes take a while.
Scott Dorman
True fact, if you're into digging through output text searching for error codes. Each to his own, I guess. ;)
Syndog
A: 

I have been working for hours and hours on a simple program and I keep getting these errors, and all anyone can say is right click the error and select "show error help"? Don't you think I thought of that before searching on the web? Nobody wants to explain it in layman's terms for someone who is trying to learn this stuff?

Bill Roberts
-1 This thread is not about solving errors, but about disabling warnings.
Les