|
|
@ -0,0 +1,32 @@ |
|
|
|
|
|
|
|
using System; |
|
|
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
using System.Linq; |
|
|
|
|
|
|
|
using System.Text; |
|
|
|
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace BasicGramms |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal class BasicLambda |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
private delegate int Calc(int x, int y); |
|
|
|
|
|
|
|
private delegate void CalcVoid() ; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void DoTest() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// lambda |
|
|
|
|
|
|
|
Calc cal = (int x, int y) => x + y; |
|
|
|
|
|
|
|
Console.WriteLine(cal(2, 5)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// anonymous method |
|
|
|
|
|
|
|
cal = delegate (int x, int y) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return x + y; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
Console.WriteLine(cal(10, 7)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CalcVoid calcVoid = () => Console.WriteLine("This is void lambda"); |
|
|
|
|
|
|
|
calcVoid(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |