How to suppress a compiler warning in C# without using #pragma ?

Posted by Dylan Lin on Stack Overflow See other posts from Stack Overflow or by Dylan Lin
Published on 2010-04-16T04:10:11Z Indexed on 2010/04/16 4:13 UTC
Read the original article Hit count: 572

Filed under:
|
|

Hi,

I need to suppress a specfic compiler warning in C#. Now I can do it like this:

#pragma warning disable 0649

private string _field;

#pragma warning restore 0649

Is there a way to do it like the following?

[SuppressCompilerWarning("0649")]
private string _field;

Because I only need to suppress warnings for this field, not a code block.

Note: I want to suppress the compiler warning, not the Code-Analysis warning.

Thanks!

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#