Getting Started with Adobe After Effects - Part 6: Motion Blur

Upload Image Close it
Select File

I am Jalpesh Vadgama a Microsoft MVP for Visual C# and BrainBench Certified ASP.NET Developer having more then 6 years of experience in .NET Technology.
Browse by Tags · View All
BRH 79
#.NET 52
C#.NET 48
ASP.NET 4.0 31
VisualStudio 27

Archive · View All
December 2010 16
July 2011 13
April 2011 13
April 2012 12
January 2011 12
June 2011 11
May 2011 11
May 2012 8
February 2013 7
January 2013 7

Multicast delegates in c#

Apr 13 2012 3:02AM by Jalpesh   

In yesterday’s post We learn about Delegates and how we can use delegates in C#. In today’s blog post we are going to learn about Multicast delegates.

What is Multicast Delegates?

As we all know we can assign methods as object to delegate and later on we can call that method with the help delegates. We can also assign more then methods to delegates that is called Multicast delegates. It’s provide functionality to execute more then method at a time. It’s maintain delegates as invocation list (linked list).

Let’s understands that via a example. We are going to use yesterday’s example and then we will extend that code multicast delegates. Following code I have written to demonstrate the multicast delegates.

using System;
namespace Delegates
    class Program
        public delegate void CalculateNumber(int a, int b);
        static void Main(string[] args)
            int a = 5;
            int b = 5;
            CalculateNumber addNumber = new CalculateNumber(AddNumber);
            CalculateNumber multiplyNumber = new CalculateNumber(MultiplyNumber);
            CalculateNumber multiCast = (CalculateNumber)Delegate.Combine (addNumber, multiplyNumber);
        public static void AddNumber(int a, int b)
            Console.WriteLine("Adding Number");
            Console.WriteLine(5 + 6); 
        public static void  MultiplyNumber(int a, int b)
            Console.WriteLine("Multiply Number");
            Console.WriteLine(5 * 6); 

As you can see in the above code I have created two method one for adding two numbers and another for multiply two number. After that I have created two same CalculateNumber delegates addNumber and multiplyNumber then I have create a multicast delegates multiCast with combining two delegates. Now I want to call this both method so I have used Invoke method to call this delegates.

As now our code is let’s run the application. Following is a output as expected.


As you can we can execute multiple methods with multicast delegates the only thing you need to take care is that we need to type for both delegates. That’s it. Hope you like it. Stay tuned for more.. Till then happy programming.

Shout it

Tags: C#.NET, Delegate, Multicast Delegate,

15 · 11% · 3548
2 Readers Liked this
Jacob Sebastian Liked this on 4/14/2012 4:01:00 AM
Profile · Blog · Facebook · Twitter
Guru Samy Liked this on 4/15/2012 11:43:00 PM
Profile · Blog


Your Comment

Sign Up or Login to post a comment.

"Multicast delegates in c#" rated 5 out of 5 by 2 readers
Multicast delegates in c# , 5.0 out of 5 based on 2 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]