Which one is similar to Delegates?

Delegate in C# is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked

You can also find related Interview Question to
Which one is similar to Delegates?
below:

Interfaces carry semantics, and when a programmer implements an interface, he is typically well aware of that semantics. When you try to invoke a particular method via an interface, you can be fairly certain that if you succeed, the semantics of that method is what you expect. For that reason, using interfaces is essentially doing a check for semantic correctness on some level.

Delegates, on the other hand, by only verifying the method signature, make the programmer responsible for ensuring that the semantics of the method is compatible. The semantics may cover not only the meaning of the arguments and return value (some times even the order of the arguments if they are of the same type), the ranges of the arguments, but also an invocation order when multiple methods are concerned. Hence, in a sufficiently large program there is plenty of margin to make an error when different programmers are not forced to comply with a uniform semantics (as they would be if interfaces were used). (More...)

.NET delegates are type safe. If you will attempt to pass a delegate, a method that does not "match the pattern", you will receive a compile time error "Method does not match delegate pattern!". (More...)

A delegate defines a reference type that can be used to encapsulate a method with a specific signature. A delegate instance encapsulates a static or an instance method. Delegates are roughly similar to function pointers in C++; however, delegates are type-safe and secure. (More...)

Delegates: To Pass methods of One Class to objects of other cloasses that can call those methods. you Can pass both static and instance Methods. C# delegates are implemented in the .Net Framework as a Class derived from System.Delegate.Use of Delegate: Declare Delegate Object with a Signature that exactly matches the method Signature that you are trying to encapsulate. Define all methods whose signature match the signature of the Delegate object that you have defined in step1. Create delegate object and plug in the methods that you want to encapsulate. Call the Encapsulate method through the Delegate Object. (More...)

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.