C# Recursion and Lambdas
A method can call itself with a base case. A lambda is a short unnamed function written with =>. Func and Action types hold them.
Example
static int Fact(int n) => n <= 1 ? 1 : n * Fact(n - 1);
Func<int, int> square = x => x * x;
Action<string> say = s => Console.WriteLine(s);
Console.WriteLine(Fact(5) + " " + square(6));
say("lambda");Exercise
Lambda arrow.
x x * 2
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.