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

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -