I made a very simple delegate program. I have no idea why this shows an error, although I compared it to the one that was listed in the MSDN library, the same one as in MSDN still does not compile ... the error says: "Add name does not exist in current context, "as well as for another method. Subtract. Please help me find what the problem is.
namespace DelegatePrac
{
public delegate void One(int a, int b);
public class Some
{
static void Add(int a, int b)
{
int c = a + b; Console.WriteLine("{0}",c);
}
static void Subtract(int a, int b)
{ int c = a - b; Console.WriteLine("{0}",c);
}
}
class Program
{
static void Main(string[] args)
{
One o1,o2;
o1 = Add;
o2 = Subtract;
o1(33,44);
o2(45, 15);
Console.ReadLine();
}
}
}
I followed this link - http://msdn.microsoft.com/en-us/library/ms173175.aspx
thank
source
share