Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

are there function pointers in c#?

I am trying to learn some c# coding and wondering if the c++ concept of function pointers is included in c#. I see there are such things as delegates. Are they the same concept? or do they differ on a more fundamental level?

like image 323
yamspog Avatar asked Apr 29 '10 16:04

yamspog


1 Answers

Delegates are essentially function pointers, but with extra multicast capabilities built in. So you can assign several functions to the same delegate, and they will all be called in sequence when the delegate is called.

Delegates also have built-in asynchronous interfaces, and have co/contra variance when assigning new functions to a delegate (and, in .NET 4, when passing delegates around)

like image 157
thecoop Avatar answered Oct 08 '22 00:10

thecoop