Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is a callback function?

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


Please Help Members By Posting Answers For Below Questions

What is the use of 0 in c#?

1085


What is _layout cshtml?

903


What are the generation of Garbage Collection in C# .NET ?

1001


Explain how to add controls dynamically to the form using c#.net.

1010


Explain the use of virtual, sealed, override, and abstract method?

938


What is the difference between finalize() and dispose()?

975


What is form feed in c#?

988


Explain partial class in c#?

966


Write a program in c# to find the angle between the hours and minutes in a clock?

987


Explane each and every methods of nterface Queue? Explain About performance issues on retrieving records

1114


What is difference between il and dll ?

1062


What is the max value of int32 in c#?

964


What is asynchronous one-way calls?

1028


Explain the difference between a sub and a function in c#.

1079


Is c sharp open source?

926