Geeks With Blogs
LD Express Quick Problem Solving Tutorials, Code Snippets and Tips in Enterprise Programming

Be it a C# Compiler or a PHP page we all have seen errors and warnings. What is the difference between them?

Error: A failing condition which prevents the compiler from proceeding further.

Warning: A condition which the compiler can tolerate and gracefully proceed. There might be little performance and/or objective degradation.

In the strictest sense I would recommend turning on the preference 'Treat Warnings As Errors' that way you would ensure that your code is very clean. However there might be situations where a warning can be safely ignored besides you can avoid the warning along with the fact save it for the future.

Say for example you do not want to bother about an exception variable in the catch block? The quickest shortcut is that you can have something like




But what happens in future you want to examine the exception? Then you have to modify the code. The other way around would be

catch (Exception exVariable)


   Debug.WriteLine (exVariable.Message);


For Visual studio this message gets written into Debug Listener and since the variable is being accessed it does not throw a warning message as well.

Posted on Friday, September 9, 2011 8:19 PM | Back to top

Comments on this post: Compiler Warnings -- What is the trick about them?

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © lavanyadeepak | Powered by: