Let's say I have a class
public class MyClass
{
public string Type { get; set; }
public int Id { get; set; }
}
and I have a collection class that is simply a strongly typed List
public class MyClassList : List<MyClass>
{
public MyClassList(IEnumerable<MyClass> enumerable) : base (enumerable) {}
}
I want MyClassList
to be able to generate a unique hash-code for MyClassList
based on the contents. The hash-code of MyClass
should be based on both properties. The hash-code of MyClassList
should be the same even if the order of the objects is different.
To handle the ordering issue I was thinking I could order the list before generating the hash-code, but I'm not sure how to generate the hash-code of the list.
MyClass.Id
s (not even counting thestring
s). – Discoverer