Avatar ·

What is the difference between Select and SelectMany in LINQ?

Hi everyone! I'm learning C# and LINQ, and I can't figure out the difference between the Select and SelectMany methods. They both seem to be used for data projection, but the result is somehow different. I have a simple model: a Student class with a Name field (string) and a Courses list (List). I want to get all the courses that students are enrolled in. Here's what I tried: ```csharp public class Student { public string Name { get; set; } public List Courses { get; set; } } var students = new List { new Student { Name = "Ivan", Courses = new List { "Math", "Physics" } }, new Student { Name = "Maria", Courses = new List { "Chemistry", "Biology" } } }; var selectResult = students.Select(s => s.Courses); var selectManyResult = students.SelectMany(s