【发布时间】:2012-11-11 10:11:22
【问题描述】:
可能重复:
C#, Operator ‘*’ cannot be applied to operands of type ‘double’ and ‘decimal’
您好,我想将插入文本框中的值相乘,但出现错误。这是我的代码。
decimal num1, num2;
if(decimal.TryParse(textBox1.Text, out num1)
&& decimal.TryParse(textBox2.Text, out num2)){
decimal ans = num1 * 0.20 + num2 * 0.20;
Label1.Text = ans.ToString();
}else{
MessageBox.Show("Please Put a number!! ");
}
我在“ans”中有错误,请帮助我。这是我的错误“运算符 * 不能应用于 'decimal' 和 double 类型的操作数;”
【问题讨论】:
-
Jay,错误信息是什么?
-
运算符 * 不能应用于“十进制”和双精度类型的操作数;
标签: c# android-activity