in Dot Net by
Q:

What is a Delegate? Explain

▼ Show 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.

Learn More with Madanswer

Related questions

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