How do I pass a method as an argument? I do this all the time in Javascript and need to use anonymous methods to pass params. How do I do it in c#?
protecte
Your ParamMethod is of type Func
So in this case, your code would become something like this:
protected void MyMethod(){
RunMethod(ParamMethod, "World");
}
protected void RunMethod(Func ArgMethod, String s){
MessageBox.Show(ArgMethod(s));
}
protected String ParamMethod(String sWho){
return "Hello " + sWho;
}