1. Back To Blog

.NET interview questions: - Different Ways to create a delegate?

This is the .NET interview questions which you come across many a times. So following is the answer to it with explanation.

Creating a delegate is four step process:-

• Declare a delegate.
• Create an object reference.
• Point the reference to the method.
• Invoke the method via the delegate.

Below is the code snippet for the same.

// Declare a delegatepublic delegate int PointToAdd(int i, int y);// Create a reference pointerPointToAdd objpointer = null;// Point to the methodobjpointer = Add;// Invoke the function/methodobjpointer.Invoke(10,20);

See the following video on different types of collection in .NET and C#: -





interview questions and answers  for .NET  for preparation of real time interviews.

Regards,

Get more from author's blogs for Most asked .NET interview questions

 

Shiv Prasad Koirala

Visit us @ www.questpond.com or call us at 022-66752917... read more

We are on Social