Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Hello Friends,


Can anyone tell me that if What exception i am using instead of Try Catch.
Posted

1 solution

Try catch is not an exception. Try catch is used to catch an exception.

C#
try
{
   // Do something that can fail..
}
catch (Exception ex)
{
   // Log exception and do something to gently 
   // tell your user that something went wrong
}
finally
{
   // Close database connections etc. if required.
}
 
Share this answer
 
Comments
Yatin chauhan 23-Jul-12 7:12am    
if i don't want to use try catch block then is there any other block or method ??
StianSandberg 23-Jul-12 7:21am    
You could catch your exceptions globally in global.asax
http://www.developer.com/net/asp/article.php/961301/Global-Exception-Handling-with-ASPNET.htm
Your question is unclear so I don't think you should downvote my answer. I'm just trying to help you..
Yatin chauhan 23-Jul-12 7:48am    
Hello AlluvialDeposit
i appreciated you for giving me nice answer. i like and solve my problem. Don't think like that i defiantly vote for you.
Thank You.
Espen Harlinn 24-Jul-12 4:38am    
5'ed!

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