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 the difference between firstordefault and first?
what is the difference between the debug class and trace class?
What is a sealed class?
What is the difference between gettype and typeof in c#?
Can constructor be private c#?
What is the difference between a class and an object c#?
What is meant by generics in c#?
Explain the process of inheriting a class into another class?
What is Inheritance in C#?
What is the default value of object in c#?
What is difference between value and reference types in C#.NET
Explain the role of the datareader class in ado.net connections?
Can you specify nested classes as partial classes?
What is the difference between continue and break statement?
What is deadly diamond problem?