複製代碼 代碼如下://普通委託
DeleteShow ds = new DeleteShow(ShowName);
Console.WriteLine("----------------------");
Console.WriteLine("普通委託----請輸入使用者名稱:");
string Name = Console.ReadLine();
Console.WriteLine(ds(Name));
Console.WriteLine("----------------------");
//匿名方法委託
DeleteShow ds2 = delegate(string NewName) {
return string.Format("匿名方法委託----輸入的使用者名稱為:{0}", NewName);
};
Console.WriteLine("----------------------");
Console.WriteLine("請輸入使用者名稱:");
string WriteName = Console.ReadLine();
Console.WriteLine(ds2(WriteName));
Console.WriteLine("----------------------");
//Lambada委託
DeleteShow ds3 = (LamName) => { return string.Format("Lambada委託----輸入的使用者名稱為:{0}", LamName); };
Console.WriteLine("----------------------");
Console.WriteLine("請輸入使用者名稱:");
string WriteLamName = Console.ReadLine();
Console.WriteLine(ds3(WriteLamName));
Console.WriteLine("----------------------");