How delegates work (in the background)?

前端 未结 6 567
温柔的废话
温柔的废话 2020-12-10 06:16

How do delegates work in c# behind the scenes and how can they be used efficiently?

EDIT: I know how they work on the surface(they are basically function pointers a

6条回答
  •  时光取名叫无心
    2020-12-10 07:02

    Delegates in C# are lists of method pointers. I.e. they store references to code, and you can invoke the methods via the pointers. This is useful in many cases. The common example is for event handlers where delegates are used to implement a publisher/subscriber pattern.

提交回复
热议问题