日期:2014-05-20  浏览次数:20790 次

c# lambda表达式(帮忙转换)
一下代码在VS2010运行成功,但是VS05不行,原因很简单c# lambda表达式这个新特性在NET Framework3.5 版本才出现的新特性,下面代码我是参考别人的,基础太差,人家写的 我转换不回来,望大虾帮忙转换下在VS05里能运行的,不要 lambda了。
随便推荐几个简单的lambda事例,我好学习下。
private void button1_Click(object sender, EventArgs e)
        {
            string url = "http://www.baidu.com";
            string script = @"<script language='javascript' type='text/javascript'>
                                        function openUrl(url){
                                        window.open(url,'测试窗口','width=1366px,height=768px,directories=true,location=false,menubar=false,resizeable=false,scrollbars=yes,toolbar=false ');
                                        }</script>";//定义脚本
            WebBrowser wb = new WebBrowser();
            wb.DocumentText = @"<html> <head>" + script + "</head><body></body></html>";//定义WebBrowser中的DOM文档
            wb.DocumentCompleted += (o, args) =>
            {
                wb.Document.InvokeScript("openUrl", new object[] { url });//执行脚本函数
            };
        }
------解决方案--------------------
自己定义一个 DocumentCompleted 事件,然后 +=绑定,就好像
button1.Click += new EventHandler(myClick);
------解决方案--------------------
Try
string url = "http://www.baidu.com";
            private void button2_Click(object sender, EventArgs e)
            { 
                string script = @"<script language='javascript' type='text/javascript'>
  function openUrl(url){
  window.open(url,'测试窗口','width=1366px,height=768px,directories=true,location=false,menubar=false,resizeable=false,scrollbars=yes,toolbar=false ');
  }</script>";//定义脚本
                WebBrowser wb = new WebBrowser();
                wb.DocumentText = @"<html> <head>" + script + "</head><body></body></html>";//定义WebBrowser中的DOM文档
                wb.DocumentCompleted+=new WebBrowserDocumentCompletedEventHandler(method);