Skip to main content

Timeline for answer to When & why to use delegates? by Benoît Vidis

Current License: CC BY-SA 4.0

Post Revisions

9 events
when toggle format what by license comment
Dec 23, 2021 at 20:31 history edited davidsbro CC BY-SA 4.0
deleted 2 characters in body
Mar 8, 2019 at 1:46 comment added DPM Are delegates considered a form of dependency injection?
Jan 31, 2017 at 0:40 comment added tcwicks Also consider it as runtime dynamic binding with many of the benefits of compile time static binding. Invocation of a delegate is orders of magnitude faster than the reflection invoke alternative. Additionally if a function signature changes such that it no longer matches the delegate this results in a compile time error which you don't get with reflection invoke. Consider for example the scenario of an MSMQ style message router. The Subscriber message receive functions could simply be stored in a dictionary of message routing key and subscriber delegate pair.
Aug 18, 2016 at 20:18 history edited chandler CC BY-SA 3.0
clarification
May 27, 2016 at 8:03 history edited EugenSunic CC BY-SA 3.0
One word fixed -> behavior
Sep 13, 2014 at 14:42 comment added Gianluca Ghettini "Please feel free to put any method that match this signature here and it will be called each time my delegate is called" -> you made my day, great explanation!
Jul 11, 2014 at 11:22 comment added Eon Personally, it feels to me that using delegates split up your code into units and make it tons more manageable. Great mechanism to use in conjunction with unit testing if most of your methods have the same signature pattern
Jan 9, 2010 at 23:04 vote accept iChaib
Jan 7, 2010 at 10:22 history answered Benoît Vidis CC BY-SA 2.5