how we can return some value in try-catch for example
try { return abc; } catch(Exception ex) { console.Writeline("Exception occur" + ex); } Try Catch is a way of handling errors in your code that cause you to need to leave the normal flow of the program. Many .net system components throw errors to indicate a condition that is not expected any code can be put in a catch block;
object x; try { x = Func(); } catch(Exception e) { //Set some default Value x = new Object(); //Send an email error SendErrorMail(); } return x; If you just need to return inside of a catch you can use a return statement just like you would anywhere else in your code.
try { return abc; } catch(Exception ex) { console.Writeline("Exception occur" + ex); return some_value; } catch block somewhat defeats the purpose of exceptions.
return?! Provide more details.