1,Delegate的代碼
public delegate void myDelegate(string str);
public static void HellowChinese(string strChinese)
{
Console.WriteLine("Good morning," + strChinese);
Console.ReadLine();
}
2,Action:指定那些只有輸入參數,沒有返回值的委托
public static void HellowChinese(string strChinese)
{
Console.WriteLine("Good morning," + strChinese);
Console.ReadLine();
}
Action<string> action = HellowChinese;
action("Spring.");
3,Func:有返回值!
public static string HelloEnglish(string strEnglish)
{
return "Hello." + strEnglish;
}
Func<string, string> f = HelloEnglish;
Console.WriteLine(f("Srping ji"));
Console.ReadLine();