I am trying to add 2 more functions to my delegate but it seems it doesn't process the functions I added. Following program outputs 5. I expect 10. Why is this the case?
using System;
namespace abc
{
public delegate int Del(int k);
class Class1
{
public int Add2(int value)
{
return value = value + 2;
}
public int Add3(int value)
{
return value = value + 3;
}
}
class Program
{
static void Main(string[] args)
{
Class1 c = new Class1();
Del mydel = c.Add2;
mydel += c.Add3;
mydel += c.Add2;
Console.WriteLine(mydel(3));
Console.ReadLine();
}
}
}