20 lines
437 B
C#
20 lines
437 B
C#
|
|
namespace Lesson14_匿名函数练习
|
||
|
|
{
|
||
|
|
class Program
|
||
|
|
{
|
||
|
|
static void Main(string[] args)
|
||
|
|
{
|
||
|
|
Func<int, int> func = Dosomething(3);
|
||
|
|
int result = func(2);
|
||
|
|
Console.WriteLine(result);
|
||
|
|
}
|
||
|
|
public static Func<int, int> Dosomething(int value)
|
||
|
|
{
|
||
|
|
return delegate (int x)
|
||
|
|
{
|
||
|
|
return value * x;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|