Wednesday 13 June 2012


·         When we use try and catch in .NET or PHP? 

The use of try and catch is to minimize the errors presented to the user and having them handled in a proper fashion by the developer.
Try is a section in which we put code that may cause an error. 
Catch will only be run if there are problems with the code being executed in try.
Finally allow the developer to clean up any code that is left open or hanging after an error occurs or execute even if there is no errors in the code,   
Try{  somecode(); }
Catch(e){  alert(e.message); }
Finally{ alert(‘Thank you’); }

No comments:

Post a Comment