Answers for "c# compare objects"

C#
0

c# compare objects

// Add the IEquatable interface to your class
public class MyObject : IEquatable<MyObject>
{        
		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
          }
}
Posted by: Guest on July-06-2021

C# Answers by Framework

Browse Popular Code Answers by Language