首页 新闻 会员 周边

c#把Form的代码改成控制台的

0
[已解决问题] 解决于 2017-07-12 08:40
Action<string> methodCall = (x) => { x += "haha"; MessageBox.Show(x); };
        public event Action<string> BoilerEventLog;
        private void button2_Click(object sender, EventArgs e)
        {
 
            BoilerEventLog += new Action<string>(methodCall);
            BoilerEventLog("123");
        }
 
我怎么改都改不对,指点一下。
某的主页 | 菜鸟二级 | 园豆:278
提问于:2017-07-06 08:00
< >
分享
最佳答案
0

MessageBox.Show(x)  换成  Console.WriteLine(x);

奖励园豆:5
ChixTech | 初学一级 |园豆:171 | 2017-07-06 09:02

 static  Action<string> methodCall = (x) => { x += "haha"; Console.WriteLine(x); };
            public static  event Action<string> BoilerEventLog;
            static void Main(string[] args)
            {               
                BoilerEventLog += new Action<string>(methodCall);
                BoilerEventLog("123");
                //Console.WriteLine(x);
                Console.ReadKey();
            }
这样才可以,可是事件和委托加了static,这样还是不是事件和委托

| 园豆:278 (菜鸟二级) | 2017-07-06 09:36
其他回答(1)
0

楼上说的没错!

星星点灯6 | 园豆:164 (初学一级) | 2017-07-07 15:27
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册