Hello I have the following code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace myConsole
{
public delegate int showDelegate();
public class addmultipleClass
{
public int addNumbers(int a, int b)
{
return (a + b);
}
public int multiplyNumbers(int a, int b)
{
return (a * b);
}
}
class Delegate
{
static void Main(string[] args)
{
addmultipleClass myObj = new addmultipleClass();
showDelegate add = new showDelegate(myObj.addNumbers);
}
}
}
It is showing error like this No overload for 'addNumbers' matches delegate 'myConsole.showDelegate'
Why it is showing this error. Whats wrong in my code. Is it not correct way to reference the addNumbers() method.
Why should i use the delegate over here. I can achieve this by using class object. as myObj.addNumbers(10,20);
So what is the need for delegate?
Please help me.
Thank you all.