Export (0) Print
Expand All

#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



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
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()

Community Additions

© 2015 Microsoft