即時消息顯示在文本框中計算的平均值和數字的問題..當我點擊顯示按鈕時,它只返回0 0值,我認爲問題出在我的字符串的讀者,但我不知道我去錯了,這裏是我的代碼問題顯示數組中存儲的數字在文本框中升序
//initialising the array
int numbers = counts;
Array.Resize(ref scoreArray, numbers);
//outputting and displaying the count in a text box
for (int count = 1; count > numbers; count++)
{
scoreArray[count] = scores;
txtCount.Text = count.ToString();
}
}
//catch statement for displaying error message
catch (Exception)
{
MessageBox.Show(" Please enter valid number ");
}
}
private void btnDisplay_Click(object sender, EventArgs e)
{
string toDisplay = string.Join(Environment.NewLine, scoreArray);
MessageBox.Show(toDisplay);
txtNumScores.Focus();
txtCount.Clear();
txtAverage.Clear();
txtNumScores.Clear();
txtTotal.Clear();
counts = 0;
total = 0;
}
private void btnClear_Click(object sender, EventArgs e)
你似乎在這裏有一個錯字:'for(int count = 1; count> numbers; count ++)'。你不是那個意思嗎......;計數<數字; ...'? – germi
你的問題是什麼? **它已經解決了嗎?如果不是,請嘗試改寫它。事實上,你使用'1-based index'作爲你的計數器,所以我想循環條件應該是'count <= numbers'。 –