-6
我正在製作一個c-sharp應用程序來轉換距離單位。 我的應用程序提示錯誤:「輸入字符串格式不正確」。由於我是新的語言,我將不勝感激。錯誤輸入字符串的格式不正確
這是我使用的代碼:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex == 0) {
label2.Text = "Miles";
label3.Text = "kilometers";
double m;
double kilometer=1.6093 ;
m = kilometer * Convert.ToDouble(textBox1.Text);//here is the problem
textBox2.Text = m.ToString();
你檢查了字符串是什麼嗎? – SLaks
你應該[編輯]你的問題,將錯誤添加爲文本而不是截圖。你的問題還應該包括哪些輸入導致了錯誤。 textBox1中有什麼? – BSMP
看起來像'textBox1.Text'的值不是以有效格式轉換爲double。 – user1666620