简体   繁体   English

为 object 的字段分配一个始终带一位小数的十进制值

[英]Assign a decimal value always with one decimal place to a field of an object

I have a legacy application where the DeductibleAmount is set to value 250.0.我有一个遗留应用程序,其中 DeductibleAmount 设置为值 250.0。 In my application I have to match to it exactly.I tried在我的应用程序中,我必须完全匹配它。我试过了

decimal.Round(ruleDeductible.Amount, 1) 

but it still shows 250 not 250.0 .但它仍然显示250而不是250.0

Is there any way to assign ruleDeductible.Amount the decimal value with a single decimal place.有没有办法分配ruleDeductible.Amount一个小数点后的十进制值。

The output of the method is passed to WebApi and the final output is json.将方法的output传递给WebApi,最终的output为json。 When I compare legacy and the new system json, I see the difference in the number of decimal points.当我比较旧系统和新系统 json 时,我看到了小数位数的差异。

json比较

The point is that I was trying out to match the legacy and the new system output via the Api Responses which is the json in the end.关键是我试图通过 Api 响应(最终是 json)来匹配旧系统和新系统 output。 So I have to deal with the formatting in json which is suggested by @Dan Rayson.所以我必须处理@Dan Rayson 建议的 json 中的格式。 Handling decimal places of decimal numbers in WebApiResponse 在 WebApiResponse 中处理小数位数的小数位

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM