1. new Action(()=>{})
2. (Action)(()=>{})
3.
public void show()
{
Action<String> messageAction;
messageAction=ShowMessage;
messageAction("HelloWorld!");}
private void showMessage(String message)
{
Console.WriteLine(message);
}
4.
public void show()
{
Action<String> messageAction;
messageAction=delegate (String s){ShowMessage(s)};
messageAction("HelloWorld!");}
private void showMessage(String message)
{
Console.WriteLine(message);
}
So we can treat Action as a method delegate with one parameter and no return value.
when declare an event, we can use like:
public event Action<String> messageArriveEvent;
messageArrive+=new Action(()=>{});