C# - Error with Method and Data Type -
i keep getting compiler error says
the best overloaded method match has invalid arguments.
it has int type. i've changed data type int still giving me error. appreciated!
private void btngetpatient_click(object sender, eventargs e) { if (validator.ispresent(txtpatientid)) { this.getpatient(txtpatientid); //add method if (patient == null) { messagebox.show("no patient found id. " + "please try again.", "patient not found"); this.clearcontrols(); } else this.displaypatient(); } } private void getpatient(int patientcode) { try { patient = patientmaintenancedb.getpatient(patientcode); //add method } catch (exception ex) { messagebox.show(ex.message, ex.gettype().tostring()); } }
the txtpatientid id of textbox not int. why error. overcome this, parsing value of txtpatientid.text:
int patientid; if(int.tryparse(txtpatientid.text, out patientid)) { this.getpatient(patientid); if (patient == null) { messagebox.show("no patient found id. " + "please try again.", "patient not found"); this.clearcontrols(); } else this.displaypatient(); }
Comments
Post a Comment