Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Delegates | Interactive GUI
Advanced C# with .NET
course content

Conteúdo do Curso

Advanced C# with .NET

Advanced C# with .NET

1. Introduction to Desktop Development with .NET
2. Interactive GUI
3. Threading
4. Generics & Reflection

book
Delegates

Important Points:

  • Delegates are types that can reference methods of a certain kind of signature;

  • Delegates allow us to pass methods as arguments;

  • The syntax of a creating a new delegate type is as follows: delegate <return type> <type name> (parameter1, parameter2, …); ;

  • We can create a variable using a delegate type and assign it a method reference using the following syntax: DelegateTypeName variableName = methodName; ;

  • More methods can be added to a delegate instance using the += operator;

  • Methods can be removed from a delegate instance using the -+ operator;

  • In case there are multiple methods in a delegate instance that return a value, the value of the last executed method is returned ;

1. What is a delegate in C#?

2. Which of the following is a correct syntax to declare a delegate named "MyDelegate" that takes an integer parameter and returns void?

question mark

What is a delegate in C#?

Select the correct answer

question mark

Which of the following is a correct syntax to declare a delegate named "MyDelegate" that takes an integer parameter and returns void?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 1

Pergunte à IA

expand
ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

course content

Conteúdo do Curso

Advanced C# with .NET

Advanced C# with .NET

1. Introduction to Desktop Development with .NET
2. Interactive GUI
3. Threading
4. Generics & Reflection

book
Delegates

Important Points:

  • Delegates are types that can reference methods of a certain kind of signature;

  • Delegates allow us to pass methods as arguments;

  • The syntax of a creating a new delegate type is as follows: delegate <return type> <type name> (parameter1, parameter2, …); ;

  • We can create a variable using a delegate type and assign it a method reference using the following syntax: DelegateTypeName variableName = methodName; ;

  • More methods can be added to a delegate instance using the += operator;

  • Methods can be removed from a delegate instance using the -+ operator;

  • In case there are multiple methods in a delegate instance that return a value, the value of the last executed method is returned ;

1. What is a delegate in C#?

2. Which of the following is a correct syntax to declare a delegate named "MyDelegate" that takes an integer parameter and returns void?

question mark

What is a delegate in C#?

Select the correct answer

question mark

Which of the following is a correct syntax to declare a delegate named "MyDelegate" that takes an integer parameter and returns void?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 1
Sentimos muito que algo saiu errado. O que aconteceu?
some-alt