using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace My
{
// public delegate int del(int a, int b);
public delegate void del(int a,int b);
class MyClass
{
//static int sum (int a, int b)
static void sum(int a,int b)
{
Console.WriteLine((a+b));
// return (a+b);
}
// static int minus (int a, int b)
static void minus(int a, int b)
{
Console.WriteLine((a-b));
// return (a-b);
}
MyClass(int y)
{
}
static void Main(string[] args)
{
del ob = new del(sum);
// Console.WriteLine("delegate received "+ob(45, 40));
ob(45, 40);
ob += new del(minus);
// Console.WriteLine("delegate received " + ob(45, 40));
ob(45, 40);
ob -= new del(minus);
// Console.WriteLine("delegate received " + ob(45, 40));
ob(45, 40);
Console.Read();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace My
{
// public delegate int del(int a, int b);
public delegate void del(int a,int b);
class MyClass
{
//static int sum (int a, int b)
static void sum(int a,int b)
{
Console.WriteLine((a+b));
// return (a+b);
}
// static int minus (int a, int b)
static void minus(int a, int b)
{
Console.WriteLine((a-b));
// return (a-b);
}
MyClass(int y)
{
}
static void Main(string[] args)
{
del ob = new del(sum);
// Console.WriteLine("delegate received "+ob(45, 40));
ob(45, 40);
ob += new del(minus);
// Console.WriteLine("delegate received " + ob(45, 40));
ob(45, 40);
ob -= new del(minus);
// Console.WriteLine("delegate received " + ob(45, 40));
ob(45, 40);
Console.Read();
}
}
}
Comments