using System;
using System.Collections.Generic;
using System.Text;
namespace 委托
{
public delegate int mydelegate(int a,int b);
class Program
{
static void Main(string[] args)
{
mydelegate calculate = new mydelegate(count.add);
calculate += count.add;//匿名方法
Console.WriteLine(calculate(5, 2));
}
}
class count
{
/// <summary>
/// 加法
/// </summary>
/// <param name="a">第一个加数</param>
/// <param name="b">第二个加数</param>
/// <returns>结果</returns>
public static int add(int a, int b)
{
return a + b;
}
}
}
using System.Collections.Generic;
using System.Text;
namespace 委托
{
public delegate int mydelegate(int a,int b);
class Program
{
static void Main(string[] args)
{
mydelegate calculate = new mydelegate(count.add);
calculate += count.add;//匿名方法
Console.WriteLine(calculate(5, 2));
}
}
class count
{
/// <summary>
/// 加法
/// </summary>
/// <param name="a">第一个加数</param>
/// <param name="b">第二个加数</param>
/// <returns>结果</returns>
public static int add(int a, int b)
{
return a + b;
}
}
}