Blog
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    APIs
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog
Report Abuse Form
Reason:    
 

Home >> C# >> Multicast Delegate in C#
Multicast Delegate in C#

What is the multicast delegate and simple demonstration?
Views: 2623     Comments: 0
by Amit Singh on 5/1/2011

Multicast Delegates

Such type’s delegates which hold and invoke multiple methods are known as multicast delegates. But simple delegates invoke only one method. Multicast delegates must satisfy the following condition:

·         The return type of the delegate must void.

·         None of the parameters of the delegate type can be declared as output parameters, using out keywords.

For Example:

delegate void Multidelegate();

    class Program

    {

        public static void Main()

        {

            Multidelegate mshow1 = new Multidelegate(Class1.show1);

            Multidelegate mshow2 = new Multidelegate(Class1.show2);

            Multidelegate mshow3 = mshow1 - mshow2;

            Multidelegate mshow4 = mshow2 - mshow1;

            Multidelegate mshow5 = mshow3 - mshow2;

            Multidelegate mshow6= mshow5 - mshow4;

            mshow3();

            mshow4();

            mshow5();

            mshow6();

            Console.ReadLine();

        }

    }   

    class Class1

    {

        static public void show1()

        {

            Console.WriteLine("India");

        }

        static public void show2()

        {

            Console.WriteLine("England");

        }

    }

Output:

India

England

India

India

Title :  
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
       
 
Report Abuse Form
Reason:    
 
Latest ArticleRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest Blogs by Amit SinghRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 5561
  
Copyright © 2013MindStick. All Rights Reserved.