Http://www.tutorialsteacher.com/csharp/csharp-action-delegate
Lambda expression
Action,func
What are lambda expressions and what are the advantages of not using lambda
Its purpose: To simplify the code.
In Java, it is common to use interfaces to implement
Action is also a delegate type defined in the System namespace. An action type delegate are the same as Func delegate except that the action delegate doesn ' t return a value. In the other words, an Action delegate can is used with a method, which has a void return type.
Action is also a delegate type it can also deduce two conclusions.
1. Action is a type, similar to an int, so you can define a variable that defines what type of variable the meaning of the variable is. One of the following inferences is required.
2. Action is a delegate type, which is a delegate, which is a function pointer that is used for calls between methods.
It contains all the characteristics of delegate, and it is different.
3. With delegate there is an action and the action is used to simplify it.
public delegate void Print(int val);
Delegate it needs to be defined first and defines the method name
Action<int> 其就直接定义形参的类型且不要返回值。
Advantages of Action and Func delegates:
- Easy and quick to define delegates.
- Makes code short.
- Compatible type throughout the application.
"Action its use of the scene"
1. Use between threads in a frame
This._readthread = Threadex.threadcall (new Action (this). Readthread));
public static System.Threading.Thread Threadcall (System.Action Action)
{
Return Threadex.threadcall (action, NULL);
}
public static System.Threading.Thread Threadcall (System.Action Action, string name)
{
Return Threadex.call (action, name);
}
public static System.Threading.Thread Call (System.Action Action, string name)
{
System.Threading.Thread Thread = new System.Threading.Thread (new System.Threading.ThreadStart (action). Invoke));
if (name! = NULL)
{
Thread. name = name;
}
Thread. Start ();
return thread;
}
Lambda expressions, Action, Func and predicate