React.js
Angular
Ethical Hacking
Agile
AWS
BlockChain
Cassandra
Cloud
Salesforce
Scaled Agile
TOGAF
DevOps
GIT
Jenkins
Jira
Kibana
Linux
NGINX
Ansible
Artificial Intelligence
in Dot Net by

What is a Delegate? Explain

Click here to read more about DevOps

1 Answer

0 votes
by

 Delegate is a variable that holds the reference to a method. Hence it is a function pointer of reference type. All Delegates are derived from System.Delegate namespace. Both Delegate and the method that it refers to can have the same signature

eclaring a delegate: public delegate void AddNumbers(int n);

After the declaration of a delegate, the object must be created of the delegate using the new keyword.

AddNumbers an1 = new AddNumbers(number);

The delegate provides a kind of encapsulation to the reference method, which will internally get called when a delegate is called.

Related questions

Madanswer
+1 vote
+1 vote
asked Jun 25, 2019 in Dot Net by Venkatshastri
+1 vote
asked Jun 25, 2019 in Dot Net by Venkatshastri
...