Chapter Summary

Let's summarize the concepts covered in this chapter.

We'll cover the following

Summary

  • The function keyword is for defining function pointers to be called later just like a function.

  • The delegate keyword is for defining delegates. A delegate is the pair of a function pointer and the context that that function pointer to be executed in.

  • A delegate can be created from an object and a member function by the syntax &object.member_function.

  • Anonymous functions and anonymous delegates (lambdas) can be used in places of function pointers and delegates in expressions.

  • There are several syntaxes for lambdas, the shortest of which is for when the equivalent consists only of a single return statement: parameter => expression.

  • A more efficient overload of toString() takes a delegate.

Get hands-on with 1000+ tech skills courses.