Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
delegate int Operation(int x, int y);
static void Main()
{
// Lambda with delegate
Operation add = (x, y) => x + y;
Console.WriteLine("Sum: " + add(5, 10));
// Lambda with LINQ
List<int> numbers = new List<int> { 1, 2, 3, 4, 5, 6 };
var evens = numbers.Where(n => n % 2 == 0);
Console.WriteLine("Even Numbers:");
foreach (var n in evens)
{
Console.WriteLine(n);
}
}
}Coding works best on desktop or with an external keyboard.