Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

pragma

I just saw this code

#pragma warning disable 659, 660, 661

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

like image 822
NLV Avatar asked Jul 14 '10 09:07

NLV


2 Answers

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.

like image 68
RvdK Avatar answered Nov 04 '22 06:11

RvdK


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

like image 31
Darin Dimitrov Avatar answered Nov 04 '22 07:11

Darin Dimitrov