Comparing object used as Key in Dictionary

前端 未结 3 940
一向
一向 2020-12-10 11:11

my class:

public class myClass
{
    public int A { get; set; }
    public int B { get; set; }
    public int C { get; set; }
    public int D { get; set; }
         


        
3条回答
  •  粉色の甜心
    2020-12-10 11:43

    Override in your myClass:

    • GetHashCode method

    • Equals method

    To implement GetHashCode method you can just XOR GetHashCodes from your integer properties.

    Optionally override ToString method and implement IEquatable interface

提交回复
热议问题