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

Comments

Popular posts from this blog

Exporting to excel from a custom class object using C#.NET

Why Dispose() is preferred than Finalize() for Un-Managed Resources in .NET?

How to apply watermark to the textbox and dropdownlist?