How to

override GetHashCode method

Published: 24. October 2011 | Updated: 24. October 2011
License: Microsoft Public License (MS-PL)
Categories: Implementations
Tags: C# Design Patterns
Was this snippet helpful for you? YESYES / NONO
public class MyClass
{
    public string Value { get; set; }
    public int Number { get; set; }
    public TimeSpan Time { get; set; }

    public override int GetHashCode()
    {
        return Value.GetHashCode() ^ Number ^ Time.GetHashCode();
    }
}
Send us feedback about this snippet »



Related Snippets: