I learned object oriented Java. Now in development in C #. This means that I never understood the functioning of delagates, but I know how to use them.
Recently, I found this page http://java.sun.com/docs/white/delegates.html .
If Java can create an event without delagates, is it possible to do the same in C #? Can we imagine our own events without writing one delegate?
(Question already asked in French here )
, . , /, . , , Invoke typafe, , - , . , : Multicast<T>, Multicast<T1, T2> .. ( , .)
Invoke
Multicast<T>
Multicast<T1, T2>
, , , .
- , -, , .
, # . # :
An event - , . event , , event, .
event
, .
Microsoft answer Sun White Paper .
, . .NET, . "Java-" , . , " " .
, . . ( , )
? , , , , : , , , .
But if you provide some code to run when an event occurs, then there is no reason not to use delegates.
Delegates are subtle abstractions over method / function pointers, and therefore they add very little overhead. And IMO, no need to add overhead just for the sake of it.