Answer Posted / m.shanmuga sundaram
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
public delegate int execute(int a, int
b); //declare a delegate method
static void Main(string[] args)
{
Program p = new Program();
execute ex = new execute(p.add);
Console.WriteLine(ex(2,3)); //add method is
executed
ex = new execute(p.subtract);
Console.WriteLine(ex(2, 3)); //subtract method
is executed
}
public int add(int a, int b)
{
return (a + b);
}
public int subtract(int a, int b)
{
return (a - b);
}
}
}
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is multidimensional array in c#?
What's the difference between class and object?
How can we make a thread sleep for infinite period ?
Explain the concepts of cts and cls(common language specification).
What is collection class c#?
What is getenumerator?
How to create events for a control? What is custom events? How to create it?
Can list contain duplicates c#?
What are extension methods and where can we use them?
What is interface inheritance?
How a two-dimensional array declared in C#?
How can I create a process that is running a supplied native executable (e.g., Cmd.exe)?
Differentiate between sqlclient oledb and providers?
How do you declare a variable in c#?
What is a struct in C#?