Last active
December 26, 2015 05:09
-
-
Save brunomikoski/7098756 to your computer and use it in GitHub Desktop.
Action example in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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