C# c中两个数字相乘时出错#

C# c中两个数字相乘时出错#,c#,C#,我找不到产品的服务税。如何获得产品的服务税?我应该使用十进制还是双精度?当使用双精度时,它不会给出错误 字符串StrVatPercentage=vatPercentage.Text decimal totalprice = Convert.ToDecimal(qty) * Convert.ToDecimal(price); // totalprice = 497080M // qty = 4 // price= 124,270.00 decimal serviceTaxPrice =

我找不到产品的服务税。如何获得产品的服务税?我应该使用
十进制
还是
双精度
?当使用双精度时,它不会给出错误

字符串StrVatPercentage=vatPercentage.Text

decimal totalprice = Convert.ToDecimal(qty) * Convert.ToDecimal(price);
    // totalprice = 497080M // qty = 4 // price= 124,270.00

decimal serviceTaxPrice = totalprice * Convert.ToDecimal(StrVatPercentage)/100;
    // strVtPercentage=12.36M- getting error in this line

我认为问题在于你对StrVatPercentage的价值。你说它等于“12.36米-”。这将不会转换,因为它的格式不正确。我负责这个

 decimal totalprice = Convert.ToDecimal("4") * Convert.ToDecimal("124,270.00");
 decimal serviceTaxPrice = totalprice * Convert.ToDecimal("12.36") / 100;

它工作得很好。

我认为问题在于你对StrVatPercentage的价值。你说它等于“12.36米-”。这将不会转换,因为它的格式不正确。我负责这个

 decimal totalprice = Convert.ToDecimal("4") * Convert.ToDecimal("124,270.00");
 decimal serviceTaxPrice = totalprice * Convert.ToDecimal("12.36") / 100;

它工作得很好。

需要一些示例值,用于
ServiceTaxPercentag.Value
StrVatPercentage
quaty
price
。哪一行有错误?它到底说了什么错误?或者它不是抛出一个错误,而是得到一个数学错误?需要一些示例值,用于
ServiceTaxPercentag.Value
StrVatPercentage
qty
price
。哪一行有错误?它到底说了什么错误?或者它不是抛出一个错误,而是得到一个数学错误?