Last Updated: February 25, 2016
·
489
· badawe

Simple action example

Here is a simple example of how use action

//C# Event using Action delegate:

public event Action OnSomeEvent;
public event Action<string> OnSomeEventWithParameters;

// Rising the event, must check if is null:
void SomeMethod()
{
    if( OnSomeEvent != null )
        OnSomeEvent();

    if( OnSomeEventWithParameters != null )
        OnSomeEventWithParameters("some parameter");
}