Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (51 sloc) 1.47 KB
title ms.custom ms.date f1_keywords helpviewer_keywords ms.assetid
#pragma warning - C# Reference
seodec18
07/20/2015
#pragma warning
#pragma warning [C#]
723493d5-9753-4cec-babb-54e2b8eb36b6

#pragma warning (C# Reference)

#pragma warning can enable or disable certain warnings.

Syntax

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

Parameters

warning-list
A comma-separated list of warning numbers. The "CS" prefix is optional.

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

[!NOTE] To find warning numbers in Visual Studio, build your project and then look for the warning numbers in the Output window.

Example

// pragma_warning.cs  
using System;  
  
#pragma warning disable 414, CS3021  
[CLSCompliant(false)]  
public class C  
{  
    int i = 1;  
    static void Main()  
    {  
    }  
}  
#pragma warning restore CS3021  
[CLSCompliant(false)]  // CS3021  
public class D  
{  
    int i = 1;  
    public static void F()  
    {  
    }  
}  

See also

You can’t perform that action at this time.