What are multicast delegates ? give me an example

Answer Posted / kirti

Delegate that can have more than one element in its invocation List.

using System;

namespace SampleMultiCastDelegate

{

class MultiCast

{

public delegate string strMultiCast(string s);

}

}

MainClass defines the static methods having same signature as delegate.

using System;

namespace SampleMultiCastDelegate

{

public class MainClass

{

public MainClass()

{

}

public static string Jump(string s)

{

Console.WriteLine("Jump");

return String.Empty;

}

public static string Run(string s)

{

Console.WriteLine("Run");

return String.Empty;

}

public static string Walk(string s)

{

Console.WriteLine("Walk");

return String.Empty;

}

}

}

The Main class:

using System;

using System.Threading;

namespace SampleMultiCastDelegate

{

public class MainMultiCastDelegate

{

public static void Main()

{

MultiCast.strMultiCast Run,Walk,Jump;

MultiCast.strMultiCast myDelegate;

///here mydelegate used the Combine method of System.MulticastDelegate

///and the delegates combine

myDelegate=(MultiCast.strMultiCast)System.Delegate.Combine(Run,Walk);

}

}

}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Describe the roles of clr in .net framework.?

831


Is .net framework 4.8 the last version?

736


Does .NET Framework support SAX?

747


Can we change web.config settings from iis?

759


What is routeconfig.cs in mvc 4?

859


Which is the root namespace for fundamental types in .net framework?

752


Asp.net mvc application, makes use of settings at 2 places for routing to work correctly. What are these 2 places?

847


What are child actions in ASP.Net MVC?

769


Explain tempdata in mvc?

737


How we can call a JavaScript function on the change of a Dropdown List in ASP.Net MVC?

745


What are the levels at which filters can be applied in an asp.net mvc application?

772


How to Create an Intranet Site Using ASP.NET MVC?

794


How route table is created in ASP.NET MVC?

780


Is it possible to cancel filter execution?

735


What does mvvm mean?

743