摘要: 委托是一种引用方法的类型。一旦为委托分配了方法,委托将与该方法具有完全相同的行为。委托方法的调用可以像其他任何方法一样,具有参数和返回值委托具有以下特点:委托类似于 C++ 函数指针,但它们是类型安全的。委托允许将方法作为参数进行传递。委托可用于定义回调方法。委托可以链接在一起;例如,可以对一个事件调用多个方法。方法不必与委托签名完全匹配。C# 2.0 版引入了 匿名方法的概念,此类方法允许将代码块作为参数传递,以代替单独定义的方法。C# 3.0 引入了 Lambda 表达式,利用它们可以更简练地编写内联代码块。匿名方法和 Lambda 表达式(在某些上下文中)都可编译为委托类型。这些功能统称 阅读全文
posted @ 2011-07-14 23:28 醉意人间 阅读(502) 评论(0) 推荐(0) 编辑
摘要: 最近在研究ArcGIS Runtime,被下面代码中的这个符号搞晕了() =>,总感觉这是一个函数,去微软的网站查了查,果不其然,这个也算一个新的东西吧,学习了,感谢群友的帮忙。 LocalServer.InitializeAsync(() => { if (LocalServer.LicenseStatus != LicenseStatus.Valid) { MessageBox.Show("This ArcGIS Runtime license is not valid"); } _graphicsLayer = MyMap.Layers["Gra 阅读全文
posted @ 2011-07-14 22:09 醉意人间 阅读(256) 评论(0) 推荐(0) 编辑
摘要: // Declare a delegate.delegate void Printer(string s);class TestClass{ static void Main() { // Instatiate the delegate type using an anonymous method. Printer p = delegate(string j) { System.Console.WriteLine(j); }; // Results from the anonymous delegate call. p("The delegate using the anonymou 阅读全文
posted @ 2011-07-14 21:48 醉意人间 阅读(379) 评论(0) 推荐(0) 编辑