asp.net - C# The best overloaded method match for ...has some invalid arguments -
public class registrationclass { sqlconnection myconnection = new sqlconnection("data source=moe-pc\\sqlexpress;initial catalog=db_university;integrated security=true;pooling=false"); connectionclass con = new connectionclass(); int id , i; string fullname, mothername, gender, placeofbirth, email, phone, adress, schooldegree, languages, highschool, faculty, major; public void setvalues (string fullname1,string mothername1,string gender1,string placeofbirth1,string email1,string phone1,string adress1, string faculty1,string major1,string schooldegree1,string languages1,string highschool1) { fullname = fullname1; mothername = mothername1; gender = gender1; placeofbirth= placeofbirth1; email =email1; phone= phone1; adress =adress1; faculty =faculty1; major =major1; schooldegree =schooldegree1; languages =languages1; highschool = highschool1; } this webform on register button click
public partial class webform1 : system.web.ui.page { protected void button_register_click(object sender, eventargs e) { string lang = ""; classes.registrationclass r = new classes.registrationclass(); r.setvalues(txt_name.tostring, txt_mothername.tostring, dropdown_gender.tostring, dropdown_pob.tostring, txt_email.tostring, txt_phone.tostring, txt_adress.tostring, dropdown_faculty.tostring, dropdown_major.tostring, dropdown_schooldegree.tostring, txt_name.tostring, txt_highschool.tostring); . . . .
here error:
the best overloaded method match 'ccharpapp.registrationclass.setvalues(string,string,string,string,string,string,string,string,string,string,string,string)' has invalid arguments.
please me guyz.
txt_name.tostring resolves method group refers tostring method. doesn't call tostring. need write txt_name.tostring(). having said that, don't want either. tostring method of textbox not return text of control. text property how text, want write: txt_name.text.
finally, should avoid functions many arguments. makes harder try determine what's wrong when have error seeing when there many arguments; there many ways off. instead registrationclass should have properties of each of values, , caller can set each property individually. quite lot easier work with.
Comments
Post a Comment