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

Does c# support const methods, properties, or events?

924


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

876


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

948


What do you mean by casting a data type?

900


What is parseexact c#?

919


What is linq c#?

852


What is a type c#?

899


What is jit? What are the different types of jit?

954


What are reflections in c#?

857


How does split work in c#?

846


What are the differences between value types and reference types?

1056


How many types of serialization are there in c#?

845


Why do we use abstract class in c#?

948


How many types of constructors are available in c#?

1008


Write a program in C# for checking a given number is PRIME or not.

1032