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 appdomain in c#?
How can we sort an array in c#?
Describe the ways of cleaning up objects in c#.
Can constructor be protected?
How do you prevent a class from being inherited?
What is the difference between hashtable and dictionary in c#?
how to print invert pyramid in c#
How can you overload a method?
Define acid rule of thumb for transactions in c#.
Difference between StackPanel and RelativePanel ?
Where’s global assembly cache located on the system?
how can i get this 123456789 1234 6789 123 789 12 89 1 9
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)