私は、華氏と摂氏の間の変換のために、これを最初のcシャープブックからこの問題を抱えています。
private void button1_Click(object sender, EventArgs e)
{
float fahr, cel;
if (Celsius.Checked == true)
{
fahr = float.Parse(textBox1.Text);
cel = (5/9)*(fahr-32);
richTextBox1.Text = "The Degree in Celsius is:" + cel.ToString() + Environment.NewLine + "cool isn't it!?";
}
else if (Fahrenheit.Checked == true )
{
cel = float.Parse(textBox1.Text);
fahr = ((9 * cel)/5)+ 32;
richTextBox1.Text = "The degree in Fahrenheit is:" + fahr.ToString() + Environment.NewLine + "cool is it!?";
}
華氏から摂氏を取得したい場合、式が正しいように見えても0を返し続けます。ここで何が問題なのですか?
問題はここにあると思うからです:
if (Celsius.Checked == true)
{
fahr = float.Parse(textBox1.Text);
cel = (5/9)*(fahr-32);
richTextBox1.Text = "The Degree in Celsius is:" + cel.ToString() + Environment.NewLine + "cool isn't it!?";
Order of Ops に何か問題があるのかもしれませんが、それは本当だと思いますか? 手伝ってくれてありがとう。