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 difference between system.string and system.text.stringbuilder classes?

941


Why do we need generics?

862


How do you convert byte array to hexadecimal string, and vice versa?

1034


What is the use of the dispose method in C# ?

914


Are c# references the same as c++ references?

946


What is difference between assembly and namespace?

866


Should I use double or float?

849


Explain About web methods and its various attributes

911


In .NET which is the smallest unit of execution?

1012


What's the difference between an integer and int?

985


Is arraylist generic in c#?

833


hi all.... i need code snippets for store and retrive tiff fromat images in sqlserver....... kindy provide it.......

1781


Can property be private in c#?

827


What are the different types of delegates?

874


Explain what is copy constructor?

955