How to throw an caught exception from cath block?
Answers were Sorted based on User's Feedback
Answer / lonesloane
try{
// code that throws exception
}
catch(Exception ex){
// Do whatever needed with exception
Console.Writeline(ex.Message);
throw; <== will re-throw the caught exception
}
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / gustav bouwer
This (as above) will re throw the exception.
catch (Exception e)
{
throw e;
}
This passes along the ORIGINAL exception so you keep your
stack trace.
catch (Exception e)
{
throw;
}
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / chandana
use the 'throw' keyword to throw an exception from a catch
block. ex,
catch (Exception e)
{
throw e;
}
Is This Answer Correct ? | 2 Yes | 3 No |
What is difference between Method and function
How can I develop an application that automatically updates itself from the web?
What are properties and indexer?
can u tell me any one steps for creatting sn.k
What are the types of access modifiers?
If you define a user defined data type by using the struct keyword, is it a value type or reference type?
How you will connect to windows directory in c#?
2 Answers HP, nTech Solutions,
What does readonly mean in c#?
What is inheritance c#?
What?s the role of the DataReader class in ADO.NET connections?
What is a namespace server?
What is namespace c#?