Thursday, April 24, 2014

Suppress the warning messages in Visual Studio

Sometimes we might have seen the warning message when we build the solution. These warning won't stop your application execution in fact these are most useful to preventing the defects.
In order to suppress this warning message we need to use the pre-processor directives i.e., "#pragma warning".
Example : As shown in the below image , the variable count is assigned and didn't used that value any where. When we build the project able to see a warning in the Error List window.

To overcome this warning we need to define the pragma warning pre-processor directive to the variable as shown below.

#pragma warning disable
  int count = 1;
#pragma warning resotre

Hope this article helped you to supress the warnings in visual studio :-)