📜  c# 比较对象 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:07.302000             🧑  作者: Mango

代码示例1
// Add the IEquatable interface to your class
public class MyObject : IEquatable
{        
        public string ID { get; set; }

        public override bool Equals(object obj) { return base.Equals(obj); }

        public bool Equals(MyObject other)
        {
            if (other == null) return false;

            return
                (object.ReferenceEquals(this.ID, other.ID) ||
                 this.ID != null && this.ID.Equals(other.ID)) &&

                //... Do the above to all your paramters
          }
}