我无法找到产品的服务税。我如何获得产品的服务税?我应该使用decimal
还是double
?使用double时不给出错误。
string 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
答案 0 :(得分:2)
我认为问题在于你对StrVatPercentage的价值。你说它等于“12.36m-”。这不会转换,因为它的格式不正确。我跑这个
decimal totalprice = Convert.ToDecimal("4") * Convert.ToDecimal("124,270.00");
decimal serviceTaxPrice = totalprice * Convert.ToDecimal("12.36") / 100;
它运作得很好。