How are delegates in C# better than function pointers in C/C++?

后端 未结 4 980
心在旅途
心在旅途 2020-12-17 15:46

The delegates in C# offer similar functionality as function pointers in C. I heard someone saying \"C# delegates are actually better than function pointers in C\". How come?

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-17 16:11

    Pointers can always point to the wrong place :) I.e it can point to a non-function or an arbitrary place in memory.

    But in terms of functionality, function pointers can do anything that delegates can do.

提交回复
热议问题