Click here to Skip to main content
16,013,207 members
Home / Discussions / C#
   

C#

 
GeneralRe: Please help with writing to a serial port Pin
turbosupramk32-Nov-11 11:37
turbosupramk32-Nov-11 11:37 
GeneralRe: Please help with writing to a serial port Pin
Rob Philpott2-Nov-11 7:34
Rob Philpott2-Nov-11 7:34 
AnswerRe: Please help with writing to a serial port Pin
PIEBALDconsult2-Nov-11 9:00
mvePIEBALDconsult2-Nov-11 9:00 
GeneralRe: Please help with writing to a serial port Pin
turbosupramk32-Nov-11 9:10
turbosupramk32-Nov-11 9:10 
AnswerRe: Please help with writing to a serial port Pin
Alan N2-Nov-11 10:12
Alan N2-Nov-11 10:12 
GeneralRe: Please help with writing to a serial port Pin
turbosupramk32-Nov-11 11:40
turbosupramk32-Nov-11 11:40 
Questionerror handling Pin
dcof1-Nov-11 17:46
dcof1-Nov-11 17:46 
AnswerRe: error handling PinPopular
Luc Pattyn1-Nov-11 18:10
sitebuilderLuc Pattyn1-Nov-11 18:10 
0. your example is pretty bad, e.g. it is missing the type of the exception you're catching.

1.
the green curly indicates the variable "ex" isn't used anywhere. If you aren't going to use it, leave out the variable's name, so write:
...
catch(FileNotFoundException) {
    log("Saving the customer data failed because the necessary file wasn't there");
}


2.
a good try-catch construct would have one or more regular statements in the try-block, and at least one in the catch-block.

3.
an empty catch block most often is very bad (it "swallows" the error information without leaving a trace). One should only catch things one can deal with, and it is always wise to log the exception.

4.
There is no connection between try-catch and using.

5.
And of course the C# reference material has told you you can have 0 or more catch-blocks and 0 or 1 finally-block; all with good examples in the doc.

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

GeneralRe: error handling Pin
Wayne Gaylard1-Nov-11 19:09
professionalWayne Gaylard1-Nov-11 19:09 
GeneralRe: error handling Pin
dcof2-Nov-11 4:13
dcof2-Nov-11 4:13 
GeneralRe: error handling Pin
fjdiewornncalwe2-Nov-11 4:21
professionalfjdiewornncalwe2-Nov-11 4:21 
AnswerRe: error handling Pin
Luc Pattyn2-Nov-11 4:25
sitebuilderLuc Pattyn2-Nov-11 4:25 
AnswerRe: error handling Pin
AditSheth1-Nov-11 18:32
AditSheth1-Nov-11 18:32 
GeneralRe: error handling Pin
Pete O'Hanlon1-Nov-11 21:04
mvePete O'Hanlon1-Nov-11 21:04 
GeneralRe: error handling Pin
BobJanova1-Nov-11 23:55
BobJanova1-Nov-11 23:55 
AnswerRe: error handling Pin
V.2-Nov-11 0:22
professionalV.2-Nov-11 0:22 
QuestionWin service jumps out Pin
suunker1-Nov-11 10:01
suunker1-Nov-11 10:01 
AnswerRe: Win service jumps out Pin
DaveyM691-Nov-11 11:22
professionalDaveyM691-Nov-11 11:22 
AnswerRe: Win service jumps out Pin
PIEBALDconsult1-Nov-11 13:32
mvePIEBALDconsult1-Nov-11 13:32 
QuestionTheming Custom Controls At Design-Time Pin
Matt U.1-Nov-11 8:48
Matt U.1-Nov-11 8:48 
AnswerRe: Theming Custom Controls At Design-Time Pin
BobJanova2-Nov-11 0:00
BobJanova2-Nov-11 0:00 
Questioncreate DSN for oracle programatically Pin
KKSharma31-Oct-11 22:56
KKSharma31-Oct-11 22:56 
AnswerRe: create DSN for oracle programatically Pin
PIEBALDconsult1-Nov-11 2:50
mvePIEBALDconsult1-Nov-11 2:50 
QuestionHelp with GetProcesses Pin
CCodeNewbie31-Oct-11 13:03
CCodeNewbie31-Oct-11 13:03 
AnswerRe: Help with GetProcesses Pin
Pete O'Hanlon31-Oct-11 20:46
mvePete O'Hanlon31-Oct-11 20:46 

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.