這是爲我的大學課程和截止日期爲2天,我仍然必須完成程序測試代碼,並在此之前評估。我有錯誤「沒有重載方法'getValidString'需要參數」。這是什麼意思,我該如何解決它?
以下是常規代碼。
public static string getValidString(string prompt, int maxLength)
{
bool valid = false;
//The paramter valid is set as a boolean and is set to false.
//It is set as a boolean because it is a small data type and
//only needs to have true or false
string tempData = "";
do // Do while loop is repetition and carries on doing it until the condition becomes true
{
Console.Write(prompt + " ?");
tempData = Console.ReadLine();
if (tempData == "")
displayMessage("You have not entered any data, please try again");
else if (tempData.Length < 3)
displayMessage("You have not entered text longer than 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 too long it must be 20 or less, please try again");
else
valid = true;
}
while (valid == false);
return tempData;
}
而我的程序中有錯誤的代碼在下面。我該如何解決?謝謝
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;
}
沒有解釋如何解決它;-) –
@MauricioGracia謝謝。更新! – JeremiahDotNet