Does using delegates slow down my programs?
I\'ve been avoiding them because I really have no clue if they make my programs any slower. I know if I cause a (catch
Delegates are very, very fast. Not quite as fast as direct method calls, but not far off. The chances of them becoming a bottleneck are miniscule.
(Likewise exceptions, when used properly, rarely actually cause a performance issue.)
Would using delegates make your code simpler, more readable, and more robust? If so, use them. Measure your performance carefully, and keep an eye on it. Move away from readability for the sake of performance only when the data is clear.
I'm sure there are some graphs around showing the speed of delegates vs interfaces vs non-virtual method calls etc - I don't know where they are, but you could always run tests yourself if you're really worried.