Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual C#
C# Reference
 #pragma warning
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
C# Language Reference
#pragma warning (C# Reference)

#pragma warning may be used to enable or disable certain warnings.

#pragma warning disable warning-list
#pragma warning restore warning-list

Parameters

warning-list

A comma-separted list of warning numbers. Enter the numbers alone, without the "CS" prefix.

When no warning numbers are specified, disable disables all warnings and restore enables all warnings.

// pragma_warning.cs
using System;

#pragma warning disable 414, 3021
[CLSCompliant(false)]
public class C
{
    int i = 1;
    static void Main()
    {
    }
}
#pragma warning restore 3021
[CLSCompliant(false)]  // CS3021
public class D
{
    int i = 1;
    public static void F()
    {
    }
}
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Request for reference to list of warnings      figaro   |   Edit   |   Show History

A reference to a list of warnings and their numbers would be handy here.

Tags What's this?: Add a tag
Flag as ContentBug
warning list      MattFenner   |   Edit   |   Show History
http://msdn.microsoft.com/en-us/library/ms228296.aspx

use the number at the end (after the zeros) as the warning number
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker