Hi all,
I want to know difference of below one
1)
catch
{
}
2)
catch(Exception ex)
{
throw ex;
}
which one is the best if your using then what is the reason for that,and give some example...
plz reply
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Suthish NairPosted Sep 13, 2013, 5:10 AM
VulpesPosted Sep 11, 2013, 7:34 AM
If you include a 'throw' statement in the first catch block, then it will re-throw the current exception as the second catch block is already doing.
However, if you need access to the Exception object - so you can print out its Message property, say - then you must use the second catch block.
Sunil PandeyPosted Sep 11, 2013, 6:42 AM
If you are using 1st point then you unable to know if your application stack some where because it not show you error message but
If you are using 2nd point then you able to know if your application stack some where.
but I recommend you to use below code :
try
{
decimal val = Convert.ToDecimal("WW");
}
catch(Exception ex)
{
MessageBox.Show (ex.Message.ToString());
}