Aug 21

Print this Post

Combine Two Delegates C#-Example

Combine Two Delegates C#

A 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.

A delegate can define its own type parameters. The generic delegate can specify the type argument to create a closed constructed type. The multicast delegate consists of a list of the assigned delegates. When the multicast delegate is called, it invokes the other delegates in the list in order. Only delegates of the same type can be combined.

Below is a C# Program to Combine Two Delegates. Here When the multicast delegate is called, it invokes the delegates in the list, in order.

Below is the Output :

Permanent link to this article: http://www.zappmania.in/2016/08/21/combine-two-delegates-c-sharp-example.htm

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">