c# sizeof decimal?

匿名 (未验证) 提交于 2019-12-03 08:35:02

问题:

Unclear on the sizeof for decimal types. Does the size in bytes vary by precision as in sql server? Is the precision variable for the c# type 'decimal'?

I don't want to turn on unsafe code to just call sizeof on a decimal type. How would you approach this?

回答1:

As others have said, decimal is always 16 bytes (128 bits). The precision of decimal is always 28/29 digits. It's a floating point type, unlike SQL's DECIMAL type. See my article on it for more details.



回答2:

The decimal keyword indicates a 128-bit data type.

Source: MSDN



回答3:

The size of a System.Decimal in the .NET Framework is fixed at 16 Bytes.



回答4:

128-bit precise decimal values with 28-29 significant digits, 128 bit = 16 byte



文章来源: c# sizeof decimal?
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!