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...

coding for delegates?

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


Please Help Members By Posting Answers For Below Questions

What is multidimensional array in c#?

1022


What's the difference between class and object?

1039


How can we make a thread sleep for infinite period ?

1037


Explain the concepts of cts and cls(common language specification).

1022


What is collection class c#?

970


What is getenumerator?

911


How to create events for a control? What is custom events? How to create it?

1047


Can list contain duplicates c#?

942


What are extension methods and where can we use them?

932


What is interface inheritance?

984


How a two-dimensional array declared in C#?

1016


How can I create a process that is running a supplied native executable (e.g., Cmd.exe)?

1141


Differentiate between sqlclient oledb and providers?

1003


How do you declare a variable in c#?

1005


What is a struct in C#?

1033