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 are the characteristics of c#?
What is the difference between <c> and <code> xml documentation tag?
What is readline c#?
How long will it take to learn c#?
3. Describe the process of interact UI to BAL n DAL?
What is Custom attribute? How to create? If I'm having custom attribute in an assembly, how to say that name in the code?
Can you have parameters for static constructors?
Why data types are important in c#?
How can you overload a method?
How many dimensions can an array have?
what is class libraries?
What does a constructor do c#?