crackyourinterview.com


To improves our performance please Like Share Subscribe(Will boost us)

Define delegates with example and its types
Question Posted on 28 Apr 2020Home >> DotNet >> C# >> Define delegates with example and its types

Define delegates with example and its types
There are certain condition when we need to pass a function as a parameter. Then to handle this a callback function and event handler comes into picture. Delegate is used to implement event and call-back methods. Below are the certain defination of delegates:-

(1)Delegate is a type which represents a references to a methods with some specific parameter list and return type.

(2)Delegate in c# is similar to function pointers of C++ but delegates are always type safe. And we can pass methods as parameters to delegate and allow delegate to point to the method and delegate used to define callback methods and implement event handling.

(3)Delegate is reference to a method its works like pointer in c and c++. But it is Secured, object-oriented and Type-safe then function pointer.

(4)Delegates are a .NET object which points to a method and its matches to a sepcific signature. And delegate can be used to invoke method.

With above 4 definition we got the idea what is delegate and now we will get types of delegates:-

(A)Single Cast Delegate
(B)Multi Cast Delegate

(A)Single Cast Delegate
Here we can refer only single method at one time. SingleCast Delegate refers only to a single method with the matching signature. And this is drived from System.Delegate class.

(B)Multi Cast Delegate
WHen we can refers multiple method at one time and signautre should be the same.

Syntax for declaring Delegates is given below

public delegate returntype delegatename(datatype varname);
0
0



.


Most Visited Questions:-

Deep Learning Questions Answers
Below are the different Deep Leaning Questions and answer a More...

Continuous Integration Questions Answers
Below are the 20 odd questions for CI or Continuous Integra More...

Derived relationships in Association Rule Mining are represented in the form of __________.
Derived relationships in Association Rule Mining are repres More...

What is Gulpjs and some multiple choice questions on Gulp
Gulpjs is an open source whihc helps in building Javascript More...

Microservices Architecture Questions Answers
Below are the different questions on Microservices Architec More...




Other Important Questions

Simplest definition of partial classes and its rules?

Definition of Tuple class with some examples?

Define Race Condition in cSharp?

C#.Net Reserve Words

can we inherit private class level variables in c#






@2014-2022 Crackyourinterview (All rights reserved)
Privacy Policy - Disclaimer - Sitemap