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 |
Types of assemblies that can be created in dotnet ?
What is the version number for the next version of the .net framework, codenamed �orcas�?
What is the difference between .net core and .net framework?
Can I customise the serialization process
What is edm in entity framework?
If I have multiple filters implemented, what is the order in which these filters get executed?
What is ViewStart Page in ASP.Net MVC?
What’s the advantage of using System.Text.StringBuilder over System.String?
What are scaffold templates in mvc?
What is CLR? How it will work?
How does CAS work
What is entitytypes? : Entity framework