var numbers = new List{ 1, 2, 3, 4, 5 }; var squaredNumbers = numbers.ToDictionary(n => n, n => n * n);
var people = new ListThis code creates a new dictionary `agesByName` from a list of `Person` objects `people`. The lambda expression `p => p.Name` extracts the person's name as the key, and `p => p.Age` extracts their age as the value. The resulting dictionary maps each person's name to their age. The System.Collections package library provides a set of collection classes that are fundamental to the .NET Framework.{ new Person("John", 25), new Person("Mary", 30), new Person("Jane", 35) }; var agesByName = people.ToDictionary(p => p.Name, p => p.Age);