Is there an equivalent to Functors
in C#?
C# has Func<,>
, delegate
s and anonymous methods but aren't all of these pointers to a method?
The C++ Functor
is a class and not a pointer to a method.
C# has Func<,>, delegates and anonymous methods but aren't all of these pointers to a method?
No. Even C# delegates are classes, implemented by the compiler for you. These generated classes (for delegates) are derived from MulticastDelegate
which in turn derives from Delegate
.
In short, a delegate is a syntactic sugar for a class generated by compiler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With