十进制值0110是否转换为72? [英] Decimal value 0110 is getting converted to 72?

查看:231
本文介绍了十进制值0110是否转换为72?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我遇到了一个我无法弄清楚的不同问题。我有一个带小数参数的模型。



Hi Guys,

Iam facing a different problem which I was unable to figure out. I have a model with decimal parameter.

public class Equipment
{
 public decimal Cost { get; set; }
public string Test1 { get; set; }
public string Test { get; set; }
}





在WebApi控制器中,我有一个接受此设备列表的方法,如下所示。





In WebApi controller I have a method which will accept this list of Equipment like below.


[HttpPost]
	    [Route("ProjectEquipments/Import")]
	    public async Task<HttpResponseMessage> Import([FromBody] List<Equipment> equipments)
	    {
 code..
}





当通过发送如下方式从post man中点击方法时..我得到的成本值为72.不确定转换的位置。任何人都可以帮我这个吗?





When hit the method from post man by sending like below.. Im getting cost value as 72. Not sure where it is getting converted. Can any one help me on this?

[
  {
    "Cost": 0110,
    "Test": "string",
    "Test1": "string",
 
  }
]





非常感谢您的帮助!!



我尝试了什么:



我无法确定转换的位置。我将转换后的值作为输入到我的控制器方法。



Thank you so much for the help!!

What I have tried:

Iam unable to figure where it is getting converted. Im getting converted value as input to my controller method.

推荐答案

0110是十进制值72的八进制表示。



使用C / C ++时,八进制值由前导零表示。似乎输入是由C / C ++的模块构建解析的(C#不支持它们)。



问题应该通过删除前导零来解决:

0110 is the octal representation for the decimal value 72.

With C/C++, octal values are indicated by a leading zero. It seems that the input is parsed by a module build from C/C++ (C# does not support them).

The problem should get solved by removing the leading zero:
[
  {
    "Cost": 110,
    "Test": "string",
    "Test1": "string",
 
  }
]


这篇关于十进制值0110是否转换为72?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆