This is not "necessary." But your main method static, therefore, it cannot call the method static. Try something like this (this is not a good way to do something - you really need to create a new class, but it does not change your choice much):
class Program
{
delegate int Fun (int a, int b);
void Execute()
{
Fun F1 = new Fun(Add);
int Res= F1(2,3);
Console.WriteLine(Res);
}
static void Main(string[] args)
{
var program = new Program();
program.Execute();
}
int Add(int a, int b)
{
int result;
result = a + b;
return result;
}
}
source
share