Try, Throw, Catch
What do the 'try', 'throw' and 'catch' blocks accomplish within your application?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Jul 25, 2013, 9:58 AM EDT
try: A try block identifies a block of code for which particular exceptions will be activated. It's followed by one or more catch blocks.
catch: A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception.
finally: The finally block is used to execute a given set of statements, whether an exception is thrown or not thrown. For example, if you open a file, it must be closed whether an exception is raised or not.
throw: A program throws an exception when a problem shows up. This is done using a throw keyword.
for details check this link
http://www.tutorialspoint.com/csharp/csharp_exception_handling.htm
Pankaj Kumar198 reputationPosted Jul 25, 2013, 9:57 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 25, 2013, 6:26 PM EDT
Please refer the below link. it is explained with example
http://msdn.microsoft.com/en-us/library/0yd65esw(v=vs.80).aspx
Regards,
Iftikar
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 25, 2013, 6:58 PM EDT
hi,
try ..catch block used for exceptions handling in C# and throw is used to throw exception to the main caller.
Please refer
http://msdn.microsoft.com/en-us/library/dszsf989(v=vs.80).aspx
http://www.dotnetperls.com/catch
hope this will help you.