为什么输出总是0?

Jar*_*rri -1 c# label textbox winforms

今天我开始使用Windows Forms在C#中使用Visual Studio 2017创建一个项目.程序应计算具有矩形底座的金字塔的体积并显示结果.

问题是,如果我单击应显示结果的按钮,结果为0.

这是重要的代码:

// stores height h, side1 a, side2 b
double a, b, h;

//Reads out b from a textbox
private void txbB_TextChanged(object sender, EventArgs e)
{
    string parseB = txbB.Text;
    b = double.Parse(parseB);
}

//Reads out a from a textbox
private void txbA_TextChanged(object sender, EventArgs e)
{
    string parseA = txbA.Text;
    a = double.Parse(parseA);
}

//Reads out h from a textbox
private void txbH_TextChanged(object sender, EventArgs e)
{
    string parseH = txbH.Text;
    h = double.Parse(parseH);
}

//button which calculates the volume of the pyramid 
//when clicked and prints it to the label "LblErgebnis"
private void Cmdrechnen_Click(object sender, EventArgs e)
{
    double Total = 1/3 * h * a * b;
    string Result = Total.ToString();
    LblErgebnis.Text = Result;
}
Run Code Online (Sandbox Code Playgroud)

有人能告诉我为什么结果总是0?

Bil*_*ard 5

在该行中double Total = 1/3 * h * a * b;,1/3是整数除法,得到0.将其更改为1.0 / 3.0.