C#实现的几种委托方式介绍
//普通委托
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("----------------------");