Click here to Skip to main content
Rate this: bad
good
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 8:30am
Comments
BC @ CV at 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 at 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
good
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.
 
—SA
  Permalink  
v2
Comments
CPallini at 7-Jan-13 15:28pm
   
That's correct (well, almost all, just a little typo shall be fixed), my 5.
:-)
Sergey Alexandrovich Kryukov at 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
Rate this: bad
good
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[^].
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 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)

  Print Answers RSS
0 OriginalGriff 490
1 Maciej Los 299
2 BillWoodruff 174
3 /\jmot 170
4 Suraj Sahoo | Coding Passion 150
0 OriginalGriff 8,484
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,159
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 7 Jan 2013
Copyright © CodeProject, 1999-2014
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