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 generic types?
Distinguish between finally and finalize blocks?
Why use a singleton instead of static methods?
Does c# have functions?
when data member or member function is static is acess specifier is considered??
Is c++ or c# better?
How does bitwise xor work?
To catch any possible exception What is the C# syntax written ?
What is callback function in c#?
What is Abstraction?
8 Answers Google, HCL, IBM, MAHINDRA, Tech Mahindra,
Code to run exe like mspaint,autocad etc in asp.net.
how to create crystal reports give one detail example(i want to view age category report) please give suitable example in my small knowledge
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)