i tried to do this like i would in C#, with an anonymous type but the result is just not correct.
VB.NET example (wrong output):
Module Module1
Sub
You need to use the Key
modifier when creating the anonymous types in the VB code. By default it creates read/write properties whereas C# anonymous types are always read-only. Only read-only properties are used in Equals
/ GetHashCode
.
For Each item In ls.GroupBy(Function(k) New With { Key .Age = k.Age, _
Key .Sex = k.Sex})
See the documentation for anonymous types in VB for more details.