Created
August 31, 2010 09:34
-
-
Save anelson/558789 to your computer and use it in GitHub Desktop.
Delegates vs Events, Kyiv 2010
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
public class UserManager { | |
//This class allows other code to perform username/password validation. Which is the better way to do this? | |
public class AuthenticateUserEventArgs : EventArgs { | |
public string UserName { get; set; } | |
public string Password { get; set; } | |
} | |
// This is one way | |
public event EventHandler<AuthenticateUserEventArgs> AuthenticateUser; | |
// This is another way | |
public Func<string, string, bool> AuthenticatedUser { get; set; } | |
} |
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
public class UserManager { | |
// This class notifies other code when a user logs on. Which is the better way to do this? | |
// This is one way | |
public event EventHandler UserLoggedOn; | |
// This is another way | |
public Action UserLoggedOn { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment