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
Does c# support const methods, properties, or events?
What is the difference between finalize() and dispose()?
What is the difference between finalize() and dispose() methods?
What do you mean by casting a data type?
What is parseexact c#?
What is linq c#?
What is a type c#?
What is jit? What are the different types of jit?
What are reflections in c#?
How does split work in c#?
What are the differences between value types and reference types?
How many types of serialization are there in c#?
Why do we use abstract class in c#?
How many types of constructors are available in c#?
Write a program in C# for checking a given number is PRIME or not.