Click here to Skip to main content
15,918,303 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to hide property @ Runtime Pin
Vertyg010-Oct-06 6:47
Vertyg010-Oct-06 6:47 
QuestionWinforms stuff Pin
jesarg6-Oct-06 5:56
jesarg6-Oct-06 5:56 
AnswerRe: Winforms stuff Pin
Amar Chaudhary6-Oct-06 8:32
Amar Chaudhary6-Oct-06 8:32 
QuestionHash Code retrieval Pin
numbers1thru96-Oct-06 5:17
numbers1thru96-Oct-06 5:17 
Questionreading game port in visual c# 2.0 [modified] Pin
Japjeet Singh6-Oct-06 5:14
Japjeet Singh6-Oct-06 5:14 
AnswerRe: reading game port in visual c# 2.0 Pin
shabonaa6-Oct-06 7:18
shabonaa6-Oct-06 7:18 
GeneralRe: reading game port in visual c# 2.0 Pin
Japjeet Singh6-Oct-06 7:58
Japjeet Singh6-Oct-06 7:58 
Questionsolution explorer Pin
Parshant Verma6-Oct-06 5:05
Parshant Verma6-Oct-06 5:05 
AnswerRe: solution explorer Pin
Amar Chaudhary6-Oct-06 8:21
Amar Chaudhary6-Oct-06 8:21 
AnswerRe: solution explorer Pin
asator6-Oct-06 9:17
asator6-Oct-06 9:17 
GeneralRe: solution explorer Pin
Amar Chaudhary6-Oct-06 9:28
Amar Chaudhary6-Oct-06 9:28 
QuestionUnit testing Database problem[VS2005] Pin
Snowjim6-Oct-06 4:44
Snowjim6-Oct-06 4:44 
Questionmdi forms Pin
shabonaa6-Oct-06 4:21
shabonaa6-Oct-06 4:21 
AnswerRe: mdi forms Pin
Ranjan Banerji6-Oct-06 5:45
Ranjan Banerji6-Oct-06 5:45 
GeneralRe: mdi forms Pin
shabonaa6-Oct-06 7:13
shabonaa6-Oct-06 7:13 
AnswerRe: mdi forms Pin
Amar Chaudhary6-Oct-06 8:16
Amar Chaudhary6-Oct-06 8:16 
QuestionTcpClient overhead Pin
Wjousts6-Oct-06 4:01
Wjousts6-Oct-06 4:01 
AnswerRe: TcpClient overhead Pin
WillemM6-Oct-06 4:39
WillemM6-Oct-06 4:39 
QuestionHandling multiple keys Pin
Bekjong6-Oct-06 3:58
Bekjong6-Oct-06 3:58 
Questionhow to change tempo of midi file Pin
Amar Chaudhary6-Oct-06 3:58
Amar Chaudhary6-Oct-06 3:58 
QuestionFormatException Pin
123456uio6-Oct-06 3:45
123456uio6-Oct-06 3:45 
AnswerRe: FormatException Pin
Martin#6-Oct-06 4:03
Martin#6-Oct-06 4:03 
GeneralRe: FormatException Pin
Guffa6-Oct-06 4:54
Guffa6-Oct-06 4:54 
GeneralRe: FormatException Pin
Martin#6-Oct-06 8:20
Martin#6-Oct-06 8:20 
GeneralRe: FormatException Pin
Guffa6-Oct-06 10:21
Guffa6-Oct-06 10:21 
Martin# wrote:
So I guess you would also recommend using double.TryParse plus cast to int, instead of try catch with Convert.ToInt32.


Yes. Exceptions are mainly for unexpected situations. If you expect something to happen, you should try to stop it before it happens.

Another alternative is to use a regular expression to validate the string before you convert it. If you have verified that a string only contains digits and not more than fits in the range of an int, you can safely convert it to an int.


---
b { font-weight: normal; }

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.