c# passing method names as the argument in a method

Posted by Alan Bennett on Stack Overflow See other posts from Stack Overflow or by Alan Bennett
Published on 2010-06-01T21:17:18Z Indexed on 2010/06/01 21:23 UTC
Read the original article Hit count: 217

Filed under:
|

hi guys,

I have a recuring method which shows up many times in my code its basically checking to make sure that the connection to the odbc is ok and then connects but each time this method is called it calls another method and each instance of the main method this one is different, as each method is about 8 lines of code having it 8 times in the code isnt ideal.

so basically i would like to have just one method which i can call passing the name of the new method as an arguement.

so basically like:

private void doSomething(methodToBeCalled) { if(somthingistrue) { methodToBeCalled(someArgument) } }

is this possible?

thanks in advance

© Stack Overflow or respective owner

Related posts about c#

Related posts about methods