.NET interview questions: - Different Ways to create a delegate?
- By Shiv Prasad Koirala in ASP.NET
- Sep 20th, 2011
- 21689
- 0
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