Answer Posted / m.shanmuga sundaram
Definition:
***********
Functions that are triggered when an associated event
happens.
example
*******
a) In C language function pointer is used as a callback
functions.
b) In C++ virtual function are used as a callback function.
c) In c# delegate keyword is used to create a call back
function.
example in c#
*************
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 ? | 11 Yes | 1 No |
Post New Answer View All Answers
Is boxing an implicit conversion?
What is the task perform by clr?
Can we inherit singleton class in c#?
What is hashset c#?
What is data bind in c#?
What is fcl in c#?
Can you inherit multiple classes in c#?
Is c# dictionary a hash table?
What is difference between property and variable in c#?
What are verbatim strings in c#?
Wcf and what is difference between wcf and web services?
Are c# tuples immutable?
Give an example to show for hiding base class methods?
is it possible to access a remote web service Without UDDI?
What is the property of class?