using System;
namespace ConsoleApplication1
{
class Class1
{
delegate double chooes(double num1,double num2);
static double add(double num1,double num2)
{
return num1+num2;
}
static double odd(double num1,double num2)
{
return num1-num2;
}
static void Main(string[] args)
{
chooes process;
bool m_bool=true;
double num;
if (m_bool)
{
process =new chooes (add);
}
else
{
process =new chooes (odd);
}
num=process(10,5);
Console.WriteLine ("{0}",num);
m_bool=false;
if (m_bool)
{
process =new chooes (add);
}
else
{
process =new chooes (odd);
}
num=process(10,5);
Console.WriteLine ("{0}",num);
}
}
} |