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

What is edm in entity framework?

623


Mention what is the difference between “ActionResult” and “ViewResult” ?

664


What are the new enhancements done in default project template of asp.net mvc 4?

657


What is entity graph? : Entity framework

602


Where are the routing rules defined in an asp.net mvc application?

632






what is entity data model?

662


what is more complex to implement property, methods or event? how can I define criteria to compare the difficulty of implementation between them? for example the number of methods wanted to implements property is 2 methods. how many methods I need it to implements events?

1794


What is model first? : Entity framework

641


How can you return string result from Action in ASP.Net MVC?

642


What is the difference between model and entity?

586


What operating systems will the .net framework 3.0 be available for?

649


Can any particular component of .net framework 3.0 be removed?

617


What is difference between Viewbag and Viewdata in ASP.NET MVC?

660


What is the version number for the next version of the .net framework, codenamed �orcas�?

584


What is page life cycle?

601