I have a custom object (DataPointCollection) with two Integer properties and a Guid property. I want that object to generate a HashCode so that no two objects with the same values in those properties are added to a HashSet. I know I need to override the GetHashCode() method, but how do I do generate a hash code to accomplish this?
Here's how I want to use it.
Dim dataPointCollections As New HashSet(Of DataPointCollection)() For Each row As DataRow In myDataSet.Tables(0).Rows Dim dataPointCollection As New DataPointCollection() dataPointCollection.ProjectID = row("ProjectID") 'Integer' dataPointCollection.RoleID = row("RoleID") 'Integer' dataPointCollection.ResourceGUID = row("ResourceGUID") 'Guid' If Not dataPointCollections.Contains(dataPointCollection) Then dataPointCollections.Add(dataPointCollection) End If Next I'm open to other ideas, but I thought this might be faster than doing a LINQ query on a collection of objects (there could be a very large number of these objects).