Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
GeneralRe: Bitmap display problem Pin
Luc Pattyn8-Jan-09 9:55
sitebuilderLuc Pattyn8-Jan-09 9:55 
GeneralRe: Bitmap display problem Pin
Member 19809998-Jan-09 9:58
Member 19809998-Jan-09 9:58 
GeneralRe: Bitmap display problem Pin
User 66588-Jan-09 10:35
User 66588-Jan-09 10:35 
GeneralRe: Bitmap display problem Pin
Member 19809998-Jan-09 10:41
Member 19809998-Jan-09 10:41 
GeneralRe: Bitmap display problem Pin
User 66588-Jan-09 10:46
User 66588-Jan-09 10:46 
GeneralRe: Bitmap display problem Pin
Luc Pattyn8-Jan-09 10:50
sitebuilderLuc Pattyn8-Jan-09 10:50 
QuestionUpdating DataBase with DataTable & TableAdapte problem ? Pin
Mohammad Dayyan8-Jan-09 9:31
Mohammad Dayyan8-Jan-09 9:31 
QuestionExceptions Pin
CodingYoshi8-Jan-09 8:52
CodingYoshi8-Jan-09 8:52 
Lets say I have a hypothetical class which does something and upon error throws exception as below:

public class Do
{
void DoSomething()
{
// do a few things
// do a few more things
if (SomethingWrong())
throw // some exception here
}
}

I understand I have the option to either create my own custom exception, throw the exception, or simply create a new Exception object and add my own message to it and link the inner exception to it.

My question is which of the above option is more ideal? Or should I throw ApplicationException?

Also in client code, which of the following is a better programming habit:

try
{
SomethingWhichCanThrowExceptionA();
SomethingWhichCanThrowExcepitonB();
// Some code here which does things and will not throw exception
}
Catch(ExceptionA)
{
// Recover
}
Catch(ExceptionB)
{
// Recover
}

Or:
try
{
SomethingWhichCanThrowExceptionA();
SomethingWhichCanThrowExceptionAPassed = true;
}
Catch(ExceptionA)
{
// Recover
}
if (SomethingWhichCanThrowExceptionAPassed)
{
try
{
SomethingWhichCanThrowExcepitonB();
SomethingWhichCanThrowExceptionBPassed = true;
}
}
Catch(ExceptionB)
{
// Recover
}

if (SomethingWhichCanThrowExceptionAPassed && SomethingWhichCanThrowExceptionBPassed)
{
// Some code here which does things and will not throw exception
}

Please shed some light on this or provide your own suggestions and how you do things.
GeneralRe: Exceptions Pin
Luc Pattyn8-Jan-09 10:02
sitebuilderLuc Pattyn8-Jan-09 10:02 
GeneralRe: Exceptions Pin
CodingYoshi8-Jan-09 10:16
CodingYoshi8-Jan-09 10:16 
GeneralRe: Exceptions Pin
Luc Pattyn8-Jan-09 10:28
sitebuilderLuc Pattyn8-Jan-09 10:28 
GeneralRe: Exceptions Pin
Jason C Bourne8-Jan-09 10:31
Jason C Bourne8-Jan-09 10:31 
GeneralRe: Exceptions Pin
CodingYoshi8-Jan-09 10:57
CodingYoshi8-Jan-09 10:57 
GeneralRe: Exceptions Pin
Colin Angus Mackay8-Jan-09 11:18
Colin Angus Mackay8-Jan-09 11:18 
GeneralRe: Exceptions Pin
Jason C Bourne8-Jan-09 11:21
Jason C Bourne8-Jan-09 11:21 
GeneralRe: Exceptions Pin
Colin Angus Mackay8-Jan-09 10:41
Colin Angus Mackay8-Jan-09 10:41 
AnswerRe: Exceptions Pin
HosamAly8-Jan-09 10:37
HosamAly8-Jan-09 10:37 
AnswerRe: Exceptions Pin
Colin Angus Mackay8-Jan-09 10:37
Colin Angus Mackay8-Jan-09 10:37 
QuestionDefaultValue() attribute problem Pin
xJorDyx8-Jan-09 8:48
xJorDyx8-Jan-09 8:48 
AnswerRe: DefaultValue() attribute problem Pin
DaveyM698-Jan-09 8:58
professionalDaveyM698-Jan-09 8:58 
GeneralRe: DefaultValue() attribute problem Pin
xJorDyx8-Jan-09 9:49
xJorDyx8-Jan-09 9:49 
GeneralRe: DefaultValue() attribute problem Pin
DaveyM698-Jan-09 13:01
professionalDaveyM698-Jan-09 13:01 
AnswerRe: DefaultValue() attribute problem Pin
Wendelius8-Jan-09 10:01
mentorWendelius8-Jan-09 10:01 
QuestionGood tutorials Pin
damennix8-Jan-09 8:17
damennix8-Jan-09 8:17 
AnswerRe: Good tutorials Pin
Mohammad Dayyan8-Jan-09 9:36
Mohammad Dayyan8-Jan-09 9:36 

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.