我写了这段代码我在if(tot = 100)时得到错误double类型的Literal不能隐式转换为十进制
//value in textboxes
decimal p1 = Convert.ToDecimal(TextBox2.Text);
decimal p2 = Convert.ToDecimal(TextBox3.Text);
decimal p3 = Convert.ToDecimal(TextBox4.Text);
decimal p4 = Convert.ToDecimal(TextBox5.Text);
decimal p5 = Convert.ToDecimal(TextBox6.Text);
decimal p6 = Convert.ToDecimal(TextBox7.Text);
//adding all the p's
decimal tot = p1 + p2 + p3 + p4 + p5 + p6;
if (tot = 100.00)
{
Label2.Text = "Percentage is 100"
}
else
{
Label2.Text = "Total of percentages is not 100.";
}
Run Code Online (Sandbox Code Playgroud)