Skip to content

Instantly share code, notes, and snippets.

@brunomikoski
Last active December 26, 2015 05:09
Show Gist options
  • Save brunomikoski/7098756 to your computer and use it in GitHub Desktop.
Save brunomikoski/7098756 to your computer and use it in GitHub Desktop.
Action example in C#
//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");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment