What do you know about delegates?
Experience Level: Medior
Tags: .NETC#
Answer
A delegate in C# is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked.
Related C# job interview questions
What is a MultiCastDelegate? What is it good for? Give some real use case
.NETC# SeniorCan you use multiple catch blocks in try/catch? What would be a use case for such thing?
C# JuniorWhat is MSIL?
.NETASP.NET MVCASP.NET WebAPIASP.NET WebFormsC# SeniorWhat is JIT?
.NETASP.NET MVCASP.NET WebAPIASP.NET WebFormsC# SeniorWrite a code that takes an integer number and outputs its digits to the console.
.NETC#Code challenge Medior
Anonymous
A delegate in C# is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked.
A delegate in C# is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked.