Original Post
I have an Object named Support. Inside that Object, I override the original Object->Equal method to suit my purpose. The purpose is to check and avoiding data duplication when the user enter new data or edit the existing data. It really really did not work. I have debug it and when I came to that part, the variable bool sama here is still generate false even when the data is the same. Variable sama should be true when the data is equals. I also have tried to use the original Object->Equals method but the result is the same. What is wrong? How to solve this? Thank you very much. for (int i = 0 ; i Count ; i++) { Support ^currsupp = dynamic_cast(lstsupport); if (supp->Equals(currsupp)) sama = true; else //dataForm->dupObj = false; sama = false; } //for int i ref class Support : Object { public: String ^SupportDate; String ^SupportName; String ^SupportTime; String ^CustComp; String ^CustName; String ^SupportType; String ^FinishTime; public: Support(){ SupportDate = ""; SupportName = ""; SupportTime = ""; CustComp = ""; CustName = ""; SupportType = ""; FinishTime = ""; } Support(String ^sdate, String ^sname,String ^stime, String ^ccomp, String ^cname, String ^stype, String ^ftime){ SupportDate = sdate; SupportName = sname; SupportTime = stime; CustComp = ccomp; CustName = cname; SupportType = stype; FinishTime = ftime; } String^ writeLine(void) { return String::Concat(SupportDate,",",SupportName,",",SupportTime, ",",CustComp,",",CustName,",",SupportType,",",FinishTime); } virtual bool Equals(Object ^obj) override { return this == dynamic_cast(obj); } static bool operator==( Support x, Support y ) { return x.SupportDate == y.SupportDate && x.SupportName == y.SupportName && x.SupportTime == y.SupportTime && x.CustComp == y.CustComp && x.CustName == y.CustName && x.SupportType == y.SupportType && x.FinishTime == y.FinishTime; } ~Support() { } };