What is Action?

前端 未结 6 761
我寻月下人不归
我寻月下人不归 2020-12-15 05:39

What is Action, how can it be used?

6条回答
  •  别那么骄傲
    2020-12-15 06:20

    This is a delegate to a function with the signature void Bla(string parameter). You can use this to pass functions to other functions. For instance you can do this

    Action action = (x => Console.WriteLine(x));
    new List{"1","2","3"}.ForEach(action);
    

    to print all characters to the console

提交回复
热议问题