2017-05-27 71 views
-2

我試着去獲得CTOTAL的75%,但因爲它是一個十進制數,它是四捨五入0.75至0,沒有人知道一個工作圍繞用一個浮點數

 decimal refundtot = order.CTotal; 
       //change it as it is making it = 0 


       refundtot = (75/100) * refundtot; 
       refund.RefundTotal = refundtot; 
+0

檢查了這一點:https://stackoverflow.com/questions/1043164/why-does-decimal-divideint-int-work-but-not-int -int –

+0

你解決了你的問題嗎? –

+0

@BobSwager是的,謝謝 – mmmmmkeyisstuckmmmmmmmmmm

回答

1

您應該乘以一個小數當你除數時使用一個十進制數。

您的代碼應該是這樣的:

efundtot = ((decimal)75/100) * refundtot;