NLV
NLV

Reputation: 21657

What is the use of #pragma warning in C#?

I just saw this code

#pragma warning disable 659, 660, 661

MSDN article is not helping much. What is the usage of this line?

Upvotes: 5

Views: 1194

Answers (2)

RvdK
RvdK

Reputation: 19800

From your link:

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

If you know some code will throw a warning but you want to ignore it, you can then use this. This will prevent the message from being shown.

Upvotes: 7

Darin Dimitrov
Darin Dimitrov

Reputation: 1039438

In C# errors and warnings have numbers. #pragma warning disable allows you to suppress some warnings that the compiler might emit.

Upvotes: 7

Related Questions