c# - I have the error "No overload for method 'getValidString' takes for arguments". What does this mean and how do i fix it? -


this college course , deadline in 2 days , still have finish program test code , evaluate before then.

below routine code.

public static string getvalidstring(string prompt, int maxlength) {     bool valid = false;      //the paramter valid set boolean , set false.      //it set boolean because small data type ,      //only needs have true or false     string tempdata = "";     // while loop repetition , carries on doing until condition becomes true     {         console.write(prompt + " ?");         tempdata = console.readline();         if (tempdata == "")             displaymessage("you have not entered data, please try again");         else if (tempdata.length < 3)             displaymessage("you have not entered text longer 3, please try again");         else if (tempdata.any(c => char.isdigit(c)))             displaymessage("you have not entered text, please try again");         else if (tempdata.length > maxlength)             displaymessage("name long must 20 or less, please try again");         else             valid = true;     }     while (valid == false);     return tempdata; } 

and code in program has error attached below. how fix this? thank you

private void btncustcont_click(object sender, eventargs e) {     txtname.text = custname[numcust];     txtphonenumber.text = custphone[numcust];     string serror = "";     serror = routine.getvalidstring("customer name", txtname.text, 3, 30);     serror += routine.getvalidstring("customer phone number", txtphonenumber.text, 3, 30);     if (serror != "")     messagebox.show(serror, "error", messageboxbuttons.ok, messageboxicon.error);      if (serror == "")         grpprint.enabled = true; } 

your method getvalidstring have 2 inputs : string prompt , int maxlength

however, you're sending 2 strings , 2 ints (for total of 4) ("customer name", txtname.text, 3, 30)

either overload getvalidstring take 4 input this

public static string getvalidstring(string prompt, string name, int length, int maxlength) 

or send 1 string , int :

routine.getvalidstring("customer phone number", 30); 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -