C# Dotnet Delegate

What is Delegate?
  • Its reference to method.
  • once method assign to delegate its work like method
  • delegate method used any other method
Where we will use real time?

If you want to call Function in Runtime .and to get data after you can call your function but method name you don't know design time but you know runtime during time you can use "Delegate"
Different type of Delegate:
Single cast Delegate
Multicast Delegate

Single cast Delegate Syntax:

Below are signature of single cast delegate

Access-modifier delegate result-type identifier ([parameters]);

Access-modifier è Its Access permission for delegate (like public ,private ..,)

Delegate è it's a Keyword

Result-type èthis is return type (like int,string,void)

Identifier è delegate name (user define)

Parameter è run time value passing

Ex :

Way 1:

public delegate void jsdelegate();

above example is no return type ,no parameter

Way 2:

public delegate string jsdelegatevalue(int x,int y);

above example is string is return type and x,y is parameter

above 2 way are delegate declaration

0 Comments

Featured Post

Improving C# Performance by Using AsSpan and Avoiding Substring

During development and everyday use, Substring is often the go-to choice for string manipulation. However, there are cases where Substring c...

MSDEVBUILD - English Channel

MSDEVBUILD - Tamil Channel

Popular Posts