zoukankan      html  css  js  c++  java
  • Func和Action

    private void button7_Click(object sender, EventArgs e)
            {
                Action<int, int> action = (x, y) => {
                    MessageBox.Show((x+y).ToString());
                };
                action(1, 2);
            }

            private void button11_Click(object sender, EventArgs e)
            {
                Action<int, int> action = delegate(int x, int y)
                {
                    MessageBox.Show((x + y).ToString());
                };
                action(1, 2);
            }

            private void button8_Click(object sender, EventArgs e)
            {
                Func<int, int, int> func = (x, y) =>
                {
                    return x + y;
                };
                int result = func(1, 2);
                MessageBox.Show(result.ToString());
            }

            private void button9_Click(object sender, EventArgs e)
            {
                Action action = delegate()
                {
                    MessageBox.Show("Hello.");
                };
                action();
            }

            private void button10_Click(object sender, EventArgs e)
            {
                Action action = () =>
                {
                    MessageBox.Show("Hello.");
                };
                action();
            }
  • 相关阅读:
    使用JdbcTemplate访问数据库
    解决为什么每次打开Eclipse新的workspace需要更新nexus-maven-repository-index问题
    java内存设置
    Eclipse如何解决启动慢
    eclipse的包的加减号展开方式
    maven总结5
    maven总结4
    maven总结3
    maven总结2
    maven总结1
  • 原文地址:https://www.cnblogs.com/RobotTech/p/1904663.html
Copyright © 2011-2022 走看看