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 does 'managed' mean in the .NET context

1 Answers  


What is NonActionAttribute ?

0 Answers   Cognizant,


how can you enhance the performance of entity framework?

0 Answers   Microsoft,


How do you do role based security ?

1 Answers   Accenture, BirlaSoft,


What is the necessity for singning an assembly with a strong name?

1 Answers   L&T,






What is "out" parameter how it is used in methods?

6 Answers   Polaris,


Explain RenderBody and RenderPage in ASP.Net MVC?

0 Answers  


What is storage model? : Entity framework

0 Answers  


what is VSS? Where we are using?

3 Answers   TCS,


what is mean by COM (component object model) and component based software development? Is it .NET is first COM based technology? Please answer me. Advance thanks.

1 Answers   Excel,


If you are using components in your application, how can you handle exceptions raised in a component ?

4 Answers   Accenture, BirlaSoft,


Is .net framework backwards compatible?

0 Answers  


Categories