Click here to Skip to main content
16,015,973 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi, how can i convert logical errors to run time errors in visual C#?
Posted
Updated 7-May-11 16:39pm
v2

When you say error do you mean exceptions?

You can use the throw keyword in C# to throw an exception like:
throw new System.ArgumentException("Parameter cannot be null");


you can also derive from System.Exception to create your own.
 
Share this answer
 
Do you know what a 'logical error' means?

Let me put up an example and then please explain me that how can ANYONE change the logical error into runtime error.

Your application has to add numbers at even indexes from a list and give an average. Instead of going even indexes you by mistake go odd indexes. Average comes in the same range as even would had. Every little syntax is perfect and code compiles perfectly without any error/warning and executes to give you the result. Anyone cannot even guess that the program is doing something wrong (Not even human looking at the result). Now, how can your code handle it and trigger an alert all by itself that there is a logical mistake and it needs to be converted to some exception or runtime error?
 
Share this answer
 
hello there
Logical errors are actually are not errors when we talk about .NET Framework.as in this case your web or Window application run and the code executes but result will be not what you expected. also on thing you may know computer always do what you tell it to be done, not what you wanted. and i am not sure about the tools to find out the logical error in application.
best regards.
 
Share this answer
 
v2
Comments
IncredibleRam 8-May-11 1:58am    
is there anything wrong with what i had wrote above (as this is what i know), just curious to know more on this concept.
best regards

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900