我在製作一個計算3D打印成本的程序。我提出這個問題。無法在2個整數中隱式地將類型'int'轉換爲'string'
private void button1_Click(object sender, EventArgs e)
{
double getal1 = Int32.Parse(textBox1.Text);
double getal2 = Int32.Parse(textBox2.Text);
double volume = 0.002405281875;
double volume1 = 0;
int dichtheidpla = Int32.Parse("1,24");
if (comboBox1.Text == "PLA")
{
//volume berekenen
volume1 = volume * getal1;
V.Text = volume1.ToString("N2");
//gewicht berekenen
int volumeberekend = Convert.ToInt32(volume1);
gewicht1.Text = volumeberekend * dichtheidpla;
}
else if (comboBox1.Text == "ABS")
{
}
}
}
當我要計算gewicht1錯誤
顯示我:不能隱式轉換類型「詮釋」到「串」。 'volumeberekend * dichtheidpla'下面有一條紅線。
1,24看起來並不像一個int。 – eckes
對於某些文化(如fr-FR),它是。 –
您正在執行數學計算,將兩個「int」類型相乘並嘗試將結果存儲在「字符串」中。 C#是一種相當強類型的語言,您不能在沒有轉換的情況下混合和匹配類型。 – sab669