zoukankan      html  css  js  c++  java
  • C#4.0 新特性 泛型委托,Action,Func用法

    //Action 无返回值 执行一个void方法

    Action<string> myAction;

    //Func 最后一个参数接受返回值
            Func<string, string> myFunc;


            Action<string> action = new Action<string>(delegate(string name)
            {
                MessageBox.Show("Hello" + name);
            });


            private void Button_Click_1(object sender, RoutedEventArgs e)
            {
                myAction = TestAction;
                myAction("myAction");

                myFunc = TestFunc;
                var a = myFunc("myFunc");
                MessageBox.Show(myFunc.ToString());
            }

            void TestAction(string a)
            {
                MessageBox.Show(a);
            }

            string TestFunc(string a)
            {
                return a;
            }

  • 相关阅读:
    ubuntu 1804 docker install
    windows shortcut
    gallary
    g++ play
    linux profile
    terminator
    tmux
    ubuntu18
    windows toolkit
    windows terminal CLI
  • 原文地址:https://www.cnblogs.com/iwangjun/p/2430558.html
Copyright © 2011-2022 走看看