C# 10 guide with Using Record Types in LINQ GroupBy - Unexpected Null Results
I'm relatively new to this, so bear with me. I'm experiencing an scenario when trying to use LINQ's `GroupBy` method with C# 10 record types. I have a record defined as follows: ```csharp public record Person(string Name, int Age); ``` I then have a list of `Person` objects that I want to group by `Age`: ```csharp var people = new List<Person> { new Person("Alice", 30), new Person("Bob", 25), new Person("Charlie", 30), new Person("David", 25) }; var groupedPeople = people.GroupBy(p => p.Age); ``` However, when I iterate over the `groupedPeople`, I find that the groups are returning `null` for some ages: ```csharp foreach (var group in groupedPeople) { Console.WriteLine($"Age: {group.Key}, Count: {group.Count()}"); } ``` The output is as follows: ``` Age: 30, Count: 2 Age: 25, Count: 2 Age: 0, Count: 0 ``` It looks like somehow the `GroupBy` is creating an additional group with a key of `0`, which doesn't correspond to any person in the list. I have checked for any potential null values or uninitialized properties, but everything seems fine. I've also tried switching to an anonymous type for grouping, but the scenario continues. I am using .NET 6, and I suspect this might be related to how records are being handled in LINQ. Has anyone else encountered similar behavior, or is there something I might be overlooking in the grouping logic? How would you solve this?