What is delegate in .NET?

0 votes
215 views
Shikhar Arora asked 07-Dec-2019 in Technology by Shikhar Arora

What is delegate in .NET

1 Answer

0 votes
Harsh Pandey answered 12-Feb-2020 by Harsh Pandey

What is delegate in .NET?

In the .NET workspace, a delegate is a command type that defines a technique signature and it can skip a feature as a parameter. In simple words we can say delegate is a .NET item which factors to a way that suits its particular signature. A delegate is a shape of type-safe function pointer utilized by the Common Language Infrastructure.

You create a delegate with the delegate keyword, observed by using a return type and the signature of the strategies that may be delegated to it. A delegate is unbiased of the kind of method that it references. The signature of the method and the delegate ought to match.

The delegate item can then be surpassed to code that may name the referenced method, without having to realize at assemble time which approach can be invoked.

It provides an awesome way to encapsulate the methods. Delegates are the library class in System namespace. 
These are the type-safe pointer of any approach. Delegates are particularly utilized in enforcing decision-again strategies and activities. 

Delegates may be chained collectively as two or greater techniques may be known as on a single event.  It doesn’t care approximately the elegance of the item that it references.