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
protected delegate String MyDelegate(String str);
protected void MyMethod()
{
MyDelegate del1 = new MyDelegate(ParamMethod);
RunMethod(del1, "World");
}
protected void RunMethod(MyDelegate mydelegate, String s)
{
MessageBox.Show(mydelegate(s) );
}
protected String ParamMethod(String sWho)
{
return "Hello " + sWho;
}