Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

What is the diff bw

catch(Exception ex)
{
throw ex;
}

and

catch(Exception ex)
{
throw;
}

Thanks
Posted

 
Share this answer
 
C#
catch(Exception ex)
{
throw;
}


It means the exception is thrown to fuction from where it is called .for example suppose you have function xyz() and in this xyz() you write "throw;" ,now u are calling xyz() function in Main() function, if there is exception then xyz() function will throw the exception to the main function.

but if you write like this

C#
catch(Exception ex)
{
throw ex;
}


then it will terminate you program.If we talk about the above scenario then the exception will thrown to the main function by XYZ().
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900