Treat Warnings as Errors - C# Coding Standard 1

In general, when we build our C# application we don’t care about warnings and we simply ignore them. But this is not advisable because warnings seriously affect the code and performance of the application. For example, we may declare several variables, but we may use only some of them not all. When we build the application all these unused variables also need to compile irrespective of whether they are used or not.

To avoid this, we need to treat warnings also as errors. To do that, open your application with Microsoft Visual Studio 2017 (or older version) and right click on the project; select properties. Under Build tab, select All option for Treat warnings as errors section as shown below.

Now let’s try to build our application with some unused variables, it produces error as shown below.