views:

25

answers:

1

Hi I have a class which derives from ContentControl and I'm not able to override GetHashCode and Equal method. I get an error

Error 5 cannot override inherited member 'System.Windows.DependencyObject.GetHashCode()' because it is sealed Is there any way to override this method ? I need to use Union method from LINQ however I need to compare object with different condition than normal. Is there any way to do it ?

+2  A: 

Yes - implement IEqualityComparer<T> separately, and pass that into the relevant overload of Union.

Basically you'll be telling it how to compare any two items for equality, and how to take the hash code of any one item. Union will use your custom comparison when building up hash sets etc. You don't need to override any existing methods.

Jon Skeet
thanks it works
pieere