How can I get a new distinct list from an existing list using LINQ? This is what I have so far and it is not distinct but does give me a new list.
Dim tmpQryColumn = (From a In _allAudits
Select New CheckBoxListItem
With {.Id = a.AuditColumn, .Name = a.AuditColumn}
).Distinct()
_columnList = New List(Of CheckBoxListItem)(tmpQryColumn)
I suspect the problem is that
CheckboxListItemdoesn’t overrideEquals/GetHashCodeso any two instances are effectively distinct. Try:I’m sure there’s a simpler way of writing it in VB, but I’m not familiar enough with the syntax to write it. The C# version would be: