tag: OS uses AR SP Div on code ad line
Namespace Lamda {Public Delegate int getnum (int A, int B); // defines the delegate with return values and parameters. Class program {static void main (string [] ARGs) {getnum = delegate (int A, int B) {return a + B ;}; // directly create an anonymous function and run it. Getnum (12, 22); console. writeline (getnum (12, 22 ). tostring (); getnum ladt = (int A, int B) =>{ return a * B ;}; // The lamada method is basically the same as the preceding method. You can also write: getnum ladt = (a, B) => {return a * B}; that is, the type definition is omitted, because when the delegate is defined, type constraints have been imposed on two parameters. Or: getnum ladt = (a, B) => A * B; this is only suitable for the method body with only one line of code. Int AA = ladt (33, 22); console. writeline (AA. tostring (); console. readkey ();}}}
Use of Lamda and anonymous functions (from www. sysoft. CC)