Distinct on custom classes

public partial class MyClass { public override bool Equals(object obj) { var item = obj as MyClass; if (item == null) { return false; } return this.num.Equals(item.num);//or GUID, or whatever makes sense to distinguish two objects } public override int GetHashCode() { return this.num.GetHashCode();//or GUID, or whatever makes sense to get the unicity of the object } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.