Click here to Skip to main content
12,898,392 members (55,932 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
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 7-Jan-13 7:30am
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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.

CPallini 7-Jan-13 15:28pm
That's correct (well, almost all, just a little typo shall be fixed), my 5.
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. :-)
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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[^].
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.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170424.1 | Last Updated 7 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100