C#6.0新添加了 lambda的强力支持,用lambda的确可以节省好多代码,让代码看起来更简洁,更直观: 这里做一个笔记,C#的匿名委托 Demo class Program { static void Main(string[] args) { List<tb_User> list = new List<tb_User>{ , Name = }, , Name = }, , Name = }, , Name = }, , Name = }, , Name = }, , Nam…
1. delegate example1 class Program { public delegate int MyDelegate(int i); int MyFunc(int i) { return i; } public void Foo() { MyDelegate f = MyFunc; Console.WriteLine(f()); Console.ReadKey(); } } example 2 // declare the delegate type public delega…
委托(delegate)也叫代理是iOS开发中常用的设计模式.我们借助于protocol(参考博文:objective-c协议(protocol))可以很方便的实现这种设计模式. 什么是代理? 苹果的官方文档给了很清晰的解释: Delegation is a simple and powerful pattern in which one object in a program acts on behalf of, or in coordination with, another object.…