c#中的委托类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
//Action委托
Action a = new Action(Program.test);
a();
//Func委托:<int, int, int> 前n-1个参数代表参数类型,最后一个参数代表返回值类型(必须有返回值)
Func<int, int, int> f = new Func<int, int, int>(Program.test);
Console.WriteLine(f(1, 2));
Console.Read();
}
public static void test()
{
Console.WriteLine("test");
}
public static int test(int a,int b)
{
Console.WriteLine(a + ":" + b);
return 0;
}
}
}
fixed
没有一个冬天不可逾越,没有一个春天不会来临。最慢的步伐不是跬步,而是徘徊,最快的脚步不是冲刺,而是坚持。