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 the difference between firstordefault and first?

892


what is the difference between the debug class and trace class?

1025


What is a sealed class?

920


What is the difference between gettype and typeof in c#?

897


Can constructor be private c#?

871


What is the difference between a class and an object c#?

966


What is meant by generics in c#?

910


Explain the process of inheriting a class into another class?

985


What is Inheritance in C#?

1156


What is the default value of object in c#?

917


What is difference between value and reference types in C#.NET

1089


Explain the role of the datareader class in ado.net connections?

895


Can you specify nested classes as partial classes?

965


What is the difference between continue and break statement?

955


What is deadly diamond problem?

973