/warn (Specify Warning Level)
- The minimum warning level you want displayed for the build. Valid values are 0-4:
Warning level Meaning 0 Turns off emission of all warning messages. 1 Displays severe warning messages. 2 Displays level 1 warnings plus certain, less-severe warnings, such as warnings about hiding class members. 3 Displays level 2 warnings plus certain, less-severe warnings, such as warnings about expressions that always evaluate to true or false. 4 Displays all level 3 warnings plus informational warnings. This is the default warning level at the command line.
The /warn option specifies the warning level for the compiler to display.
The Build Errors documentation describes the warnings, indicates each warning's level, and indicates potential problems (rather than actual coding errors) with statements that may not compile as you intend.
/w is the short form of /warn.
To set this compiler option in the Visual Studio development environment
- Open the project's Property Pages dialog box. For details, see Setting Visual C# Project Properties.
- Click the Configuration Properties folder.
- Click the Build property page.
- Modify the Warning Level property.
To set this compiler option programmatically
See WarningLevel Property.
in.cs and have the compiler only display level 1 warnings:
csc /warn:1 in.cs