//Add comments here that explain the Sqrt method
private void btnSqrt_Click(object sender, EventArgs e)
{
double num = double.Parse(textDisplay.Text);
if (num >= 0)
{
textDisplay.Text = SquareRoot(num).ToString();
}
else
{
MessageBox.Show("Number must be positive", "Error Message");
textDisplay.Text = "0";
}
}
//Add comments here that explain the Sqrt function
//What are the arguments and the return value(s)
//To Do – Add the math sqrt method.
private double SquareRoot(double x)
{
textDisplay.Text = Convert.ToString(Math.Sqrt(Convert.ToDouble(x)));
}
我遇到了數學sqrt方法的麻煩。 對於這個問題我一直在給第一行
私人雙SquareRoot(雙x) 我試圖寫的方法,但我有一個紅線在SquareRoot下。 我的方法怎麼了? 感謝 它的一個計算器數學sqrt函數。我在想什麼
你應該學會看幫助VS來這裏之前提供近了!它肯定告訴你,你的方法缺少你在簽名中承諾的返回值。 – TaW