gpt4 book ai didi

c# - 将 TextBox 乘以一个值

转载 作者:行者123 更新时间:2023-11-30 15:01:55 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
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”中遇到错误,请帮助我。这是我的错误“Operator * cannot be applied to operands of type 'decimal' and double;”

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com