c# - try-catch block -
i have class different methods doing same thing reading file. want use try-catch block exception handling. want ask if there way methods go inside single try block every method give same exception "file not found"..
my preferred way of handling call common method of them, each (individually) looks like:
try { // code } catch(someexceptiontype ex) { dosomethingaboutthat(ex); }
however, can delegates, i.e.
void execute(action action) { try { // code } catch(someexceptiontype ex) { // } }
and
execute(() => {open file});
Comments
Post a Comment