using System;
namespace DelegatesCode
{
class Program
{
static void Main(string[] args)
{
Arithmetic method1,method2,combine;
method1=new Arithmetic(add);
method2=new Arithmetic(subtract);
combine = method1 + method2;
combine(10,8);
Console.ReadKey();
}
public delegate void Arithmetic(double no1,double no2);
public static void add(double num1, double num2)
{
Console.WriteLine(num1+num2);
}
public static void subtract(double number1, double number2)
{
Console.WriteLine(number1 - number2);
}
}
}
namespace DelegatesCode
{
class Program
{
static void Main(string[] args)
{
Arithmetic method1,method2,combine;
method1=new Arithmetic(add);
method2=new Arithmetic(subtract);
combine = method1 + method2;
combine(10,8);
Console.ReadKey();
}
public delegate void Arithmetic(double no1,double no2);
public static void add(double num1, double num2)
{
Console.WriteLine(num1+num2);
}
public static void subtract(double number1, double number2)
{
Console.WriteLine(number1 - number2);
}
}
}
Comments
Post a Comment