Public Property anonymousDelegate As [Delegate]
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        anonymousDelegate = Function(x)
                               TextBox1.Text = x : Return "Hello"
                            End Function
      TextBox3.Text = anonymousDelegate.DynamicInvoke(TextBox2.Text)
    End Sub

解决方案 »

  1.   


    public delegate string ReturnValue(string strvalue);string sReturn(string strvalue)
    {
         return strvalue;
    }protected void Button1_Click(object sender, EventArgs e)
    {
         ReturnValue re = sReturn;
         string a = re("hello");
    }
      

  2.   

    Public Delegate Property anonymousDelegate;
    Button3.Click+=Button3_Click;
    Private void Button3_Click(object sender,System.EventArgs e)
    {
        anonymousDelegate=delegate(string x){TextBox1.Text = x;return "Hello"};
        TextBox3.Text = anonymousDelegate.Invoke(TextBox2.Text);
    }
      

  3.   

    你这个代码不对!C#中Public 应为public,代码不能用!!
      

  4.   

    ....我就没在编译器里编译,copy你的代码,带进来的
      

  5.   


    public delegate Property anonymousDelegate;
      

  6.   

    根据需要加
                this.button3.Click += new System.EventHandler(this.button3_Click);
    这句话
            public Delegate anonymousDelegate { get; set; }        private void button3_Click(object sender, EventArgs e)
            {
                this.anonymousDelegate = new Func<String, String>((x) =>
                {
                    this.textBox1.Text = x;
                    return "Hello";
                });
                this.textBox3.Text = (string)this.anonymousDelegate.DynamicInvoke(textBox2.Text);        }
      

  7.   

    其实你这个委托是在内部赋值,直接
    textbox1.text=textbox2.text
    textbox3.text=“Hello"
    不就可以了么?
      

  8.   

    http://www.developerfusion.com/tools/convert/csharp-to-vb/
      

  9.   

    10#,谢了,再问一下,下面的代码,对应的C#?        anonymousDelegate = Sub(x)
                                    TextBox1.Text = x
                                End Sub
      

  10.   

    将:
     Public Property anonymousDelegate As [Delegate]
            anonymousDelegate = Sub(x)
                                    TextBox1.Text = x
                                End Sub
    变成了:
    public Delegate anonymousDelegate { get; set; } anonymousDelegate = x => { TextBox1.Text = x; };可是代码不好用!
      

  11.   

    将你的代码生成 一个DLL用Refector反编译 生成的Dll有个语言选择,选成 C# 或者 VB,看你想怎么反编译了
      

  12.   


    vb.net可以直接把匿名方法赋值给委托,c#不行,要new一个匿名委托,将匿名方法作为参数            anonymousDelegate = new Action<String>((x) =>
                {
                    this.textBox1.Text = x;
                });
      

  13.   

    下面翻译出来的代码根本就不好用! :
    public Delegate anonymousDelegate { get; set; }
     anonymousDelegate = x => { TextBox1.Text = x; };
      

  14.   

    手工给你转的public Func<string, string> anonymousDelegate { get; set; }
    private void button3_Click(object sender, EventArgs e)
    {
        anonymousDelegate = x =>
            {
                textBox1.Text = x;
                return "Hello";
            };
        textBox3.Text = anonymousDelegate(textBox2.Text);
    }
      

  15.   


    Public Property anonymousDelegate As [Delegate]
    public Func<string, string> anonymousDelegate { get; set; }他的委托类型是Delegate,你改成Func<string, string>,这样不行的吧,这个属性可是公开的,而且还可能是Action<String>类型的。