I am confronted with a task from an old exam, and I have no idea what it is about:
class Demo
{
satic void Main()
{
Func <int,int> xxx = null;
xxx = n => n <= 1 ? 1:n * xxx(n-1);
for (int m=1; m < 6; m++)
{
Console.WriteLine("m= {0} xxx = {1}", m, xxx(m));
}
}
}
There is some generic construct with type int,int but what is this? There is an if-else statement, but what is happening here? Especially with the => operator? I would be very thankful if someone could tell me what is happening here.
We should correct this code and write down the print out. But we do not know what happens in the first lines.
Update: In Visual Studio, no errors are found. So why should we find an error then? The output is the following:
m=1 xxx=1
m=2 xxx=2
m=3 xxx=6
m=4 xxx=24
m=5 xxx=120
It is still unclear to me what is happening.