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();
            }
  • 相关阅读:
    面试常见问题
    Servlet上传下载
    Java五大框架
    Jquery
    JavaEE
    Html学习
    JavaSE高级
    面向过程基础
    Java开发软件安装及配置
    JAVA的类加载机制和Class类
  • 原文地址:https://www.cnblogs.com/RobotTech/p/1904663.html
Copyright © 2011-2022 走看看