Click here to Skip to main content
15,912,072 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I use int.parse and my program doesn't run and go to the debug mode
what should I do?
I have this problem on many programs that I have written since so far
help me guys
Posted
Comments
BC @ CV 7-Jan-13 13:35pm    
When you say, "...doesn't run and go to the debug mode..." do you mean it is a compiled .exe you're running and it throws an un-handled error? If so I would say that is happening because you're trying to parse a non-integer string. You can account for this by int.TryParse or adding an error catch.
Jibesh 7-Jan-13 13:35pm    
check your build settings, it must be in debug , change this to Release mode. you can also try Ctrl+F5 instead of F5 to run without starting the debugger.

Your program is not going to "debug mode", just because there is no such think as "debug mode". This is simply not how debuggers work. What happens happens only if you execute it under the debugger from the very beginning, and something invokes the debugger. If you just execute it from the Shell, something else will happen; and it may depends on how you handle exception. I may request the user to start debugging, or it may just pass through, or "crash". One possible and very likely reason is the one explained in Solution 1.

—SA
 
Share this answer
 
v2
Comments
CPallini 7-Jan-13 15:28pm    
That's correct (well, almost all, just a little typo shall be fixed), my 5.
:-)
Sergey Alexandrovich Kryukov 7-Jan-13 15:39pm    
Thank you, Carlo, especially for a fix of a funny typo. :-)
It already happened to me: the editor decided it was a wordplay, and they printed my article with my typo. :-)
—SA
Probably you are not handling an exception (possibly bad format) thrown by the Parse method. You might either:
  • Explicitely handle such exception.
  • Use the TryParse[^] (checking the return value).

See, for instance "What is better: int.TryParse or try { int.Parse() } catch" at Stack Overflow[^].
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-Jan-13 15:07pm    
This is really very likely; my 5.
I added my answer to explain that the "debug mode" is a misconception, a very typical one — please see.
—SA

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