You have modified and broken sample code from the book Professional C# 2008 published by Wrox. Why don't you just go back to the original to see what you have done wrong?
It available here
Sample code download[
^]
For your convenience here is the code that you have broken.
using System;
using System.Collections.Generic;
using System.Text;
namespace Wrox.ProCSharp.Delegates
{
class MathOperations
{
public static double MultiplyByTwo(double value)
{
return value * 2;
}
public static double Square(double value)
{
return value * value;
}
}
delegate double DoubleOp(double x);
class MainEntryPoint
{
static void Main()
{
DoubleOp[] operations =
{
MathOperations.MultiplyByTwo,
MathOperations.Square
};
for (int i = 0; i < operations.Length; i++)
{
Console.WriteLine("Using operations[{0}]:", i);
ProcessAndDisplayNumber(operations[i], 2.0);
ProcessAndDisplayNumber(operations[i], 7.94);
ProcessAndDisplayNumber(operations[i], 1.414);
Console.WriteLine();
}
}
static void ProcessAndDisplayNumber(DoubleOp action, double value)
{
double result = action(value);
Console.WriteLine(
"Value is {0}, result of operation is {1}", value, result);
}
}
}
Alan.