Last active
February 23, 2017 11:48
-
-
Save tracer8/f8a56b9056919352d38883cab37c51af to your computer and use it in GitHub Desktop.
C# Delegate Generic ASK
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
// IEventParameterBase la 1 interface rỗng | |
public delegate void EventDelegateGeneric (T eventParam) where T : IEventParameterBase; | |
private delegate void EventDelegate(IEventParameterBase eventParam); | |
public EventDelegate myDelegate; | |
public void AddDelegate(EventDelegateGeneric eventDelegate) where T : IEventParameterBase | |
{ | |
// Tai sao cai lamda express kia lai co the chuyen duoc tu EventDelegateGeneric thanh EventDelegate? | |
// và nếu viết thành một hàm riêng thì cái lamda đó sẽ được viết như thế nào? | |
EventDelegate internalDelegate = (eventParam) => eventDelegate((T)eventParam); | |
myDelegate += internalDelegate | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment