C#: Delegates, Events, and Lambdas

C#: Delegates, Events, and Lambdas

1h 7mIntermediate2023-12-14

Authors

Joe Marini

Joe Marini

Senior Developer Advocate at Google, Developer

Course details

C# provides different function types to fit a variety of real-world development scenarios. In this course, Joe Marini explores three important features of C#: Delegates, events, and lambdas. First, Joe shows how delegates are used to provide interchangeable functions during the lifetime of a program, which makes it easy to modify the functionality of an app on the fly. He then covers events, which are used to handle messages from both within and outside the program and can be turned on and off dynamically. Finally, he shows how lambdas provide a concise, efficient way of writing simple expressions without having all the associated syntax of a full function. These features help keep C# code readable, efficient, and maintainable, so join Joe to learn how to adapt this flexible set of programming tools to your own C# programming needs.

Skills covered

C#Programming LanguagesMicrosoftSoftware DevelopmentDeep Dive (X:Y)

Concepts

Introduction

  • Using C# delegates, events, and lambdas
  • What you should know
  • Exercise files on GitHub
  • Setting up the developer environment

Getting Started

  • Overview of C# delegates, events, and lambdas
  • Common delegate, event, and lambda scenarios

C# Delegates

  • Creating C# delegates
  • Using anonymous delegates
  • Using composable delegates
  • Challenge - Programming delegate
  • Solution - Programming delegate

C# Events

  • Creating C# event handlers
  • Event chaining
  • Challenge - Programming events
  • Solution - Programming events

C# Lambdas

  • Understanding C# lambdas
  • Using lambdas as delegates
  • Challenge - Programming lambdas
  • Solution - Programming lambdas

Conclusion

  • Where to go next
40,000 Toman