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
can you declare an override method to be static if the original method is not static?
What is the use of generics in c#?
What is icomparable in c#?
Why interface is required?
What is yield c#?
How to find type of variable?
What is overloading with example?
Hi to all..I have to create an intranet application on C#.NET windows Application so please please let can you people help me as iam new in .NET and if u have any samples or website address from where i can get sample please let know.
Explain the Abstract class in c#.net
Can a class or a struct have multiple constructors?
Explain more on CLR
Why dictionary is faster than list?
What is boxing & unboxing?
How is lazy loading achieved?
What is immutable in C#?