Sometimes during development you may need to avoid the unnecessary compiler warnings to show in warning window. Though it’s not recommended to suppress the warning explicitly, but during some debugging and analysis of code you may want to hide them for time being. In this post I have explained how you can hide the unwanted warning explicitly by specifying the warning number.
To suppress the warning you need to use #pragma warning directives in your code. Below is the syntax for the same.
#pragma warning disable <warning-Numbers>
[Line of Code ]
Let’s consider you are having the below code block and you want to suppress the warning messages.
If you are going to build the above code, you will find the below warning messages.