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 |
What is entitytype? : Entity framework
Explain the advantages and disadvantages of ASP.Net MVC over ASP.NET?
Which is the best institute in chennai to learn DotNet?
Explain the advantages of asp.net mvc over asp.net?
mention what is the key advantage of using entity framework or ef?
Difference between Dispose and Finalize method
Is there built-in support for tracing/logging
Difference between ASP.NET MVC and ASP.NET WebForms?
VIEWS WITH SYNTAX AND EXAMPLE IN SQL
What is the difference between Finalize and Dispose (Garbage collection)
Why is XmlSerializer so slow
When do you absolutely have to declare a class as abstract