简体   繁体   中英

Cannot assign to 'click' because it is a 'method group'

I'm using linux monodevelop to do c# stuff , what is wrong with this ?

?

using System;
using Gtk;

namespace aaadd
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            Application.Init ();
            MainWindow win = new MainWindow ();
            Button button = new Button();

            button.Click += new EventHandler (button_Click);
            win.Add (button);
            button.Show ();
            win.Show ();

            Application.Run ();
        }
        public static void button_Click(object sender, System.EventArgs e) 
        {

        }

    }
}

Error :

Cannot assign to 'click' because it is a 'method group'

要订阅活动,您需要使用

button.Clicked += new EventHandler (button_Click);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM