What are multicast delegates ? give me an example



What are multicast delegates ? give me an example..

Answer / 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

More Dot Net Framework Interview Questions

What are Action Filters in ASP.NET MVC and its use?

0 Answers  


What's the difference between Java and .NET garbage collectors ?

1 Answers   BirlaSoft,


What's the difference between const and readonly ?

2 Answers  


Why to use “{resource}.axd/{*pathinfo}” in routing in mvc?

0 Answers  


Explain the methods used to render the views in mvc?

0 Answers  






How to ensure the credentials for WebService using Windows authentication

1 Answers   Proteans,


Define the core components of an ASP.NET MVC application?

0 Answers  


explain what does .edmx file contains?

0 Answers   Microsoft,


What is oauth in web api?

0 Answers  


exe abrevatiom

5 Answers   IBM,


Is entity framework slow?

0 Answers  


What are the 2 popular asp.net mvc view engines?

0 Answers  


Categories