Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. public override bool Equals(object objet)
  2. {
  3. PropertyInfo[] propertiesThis = this.GetType().GetProperties();
  4. PropertyInfo[] propertiesObj = objet.GetType().GetProperties();
  5.  
  6. if (propertiesThis.Length == propertiesObj.Length)
  7. {
  8. for (int i = 0; i < propertiesThis.Length; i++)
  9. {
  10. if (!propertiesThis[i].GetValue(this, null).Equals(propertiesObj[i].GetValue(objet, null)))
  11. {
  12. Console.Out.WriteLine(propertiesThis[i].Name + " != " + propertiesObj[i].Name);
  13. Console.Out.WriteLine(propertiesThis[i].GetValue(this, null) + " != " + propertiesObj[i].GetValue(this, null));
  14. return false;
  15. }
  16. }
  17. return true;
  18. }
  19. return false;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement